Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does initializing a repository with a README help in letting you immediately clone the repository to your computer?

Tags:

git

github

github repository creation How are they connected in any way?

like image 442
KannarKK Avatar asked Jun 10 '15 14:06

KannarKK


1 Answers

git can perfectly clone an empty repository.

But in that case, you end-up with a repo with no branch, which can be unsettling for Git beginners.

That also means that, when you create your own commit in that empty cloned repo, you need to setup the upstream branch on the first push, with a git push -u origin master.
Again, a bit of a hassle when you discover Git.
See "Why do I need to explicitly push a new branch?"

Hence the recommendation for creating at least one file, meaning at least one commit in a master branch.
Plus, the cloned repo now has a local master branch with its upstream branch already setup: when new commits are done locally, a simple git push is enough to send them to the GitHub repo.

Those two points (local repo with a master branch, and with a remote tracking branch origin/master) make for an easier experience.

If you are importing an existing repo, on the other hand, you would want an empty repo to begin with.

like image 134
VonC Avatar answered Nov 12 '22 18:11

VonC