Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Is using "origin master" really necessary? #716
I'm not convinced (in the current form of the notes) that specifying "origin master" everywhere adds enough value to be worth including.
Typically, I'd always write "git pull" or "git push" and never worry about the "origin master" part.
I can't think of many sensible cases where a user would want to specify the "origin master" variant:
I admit this is slightly confusing, but I don't think that this message is worth teaching that we should be typing "git pull" and "git push" everywhere.
Anyone else have any thoughts on this?
omsai@xm2:~$ cd /tmp/ omsai@xm2:/tmp$ mkdir repo-local omsai@xm2:/tmp$ cd repo-local omsai@xm2:/tmp/repo-local$ git init Initialized empty Git repository in /tmp/repo-local/.git/ omsai@xm2:/tmp/repo-local$ touch test.txt omsai@xm2:/tmp/repo-local$ git add test.txt omsai@xm2:/tmp/repo-local$ git commit -m "Initial commit" [master (root-commit) 9aa30c7] Initial commit 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 test.txt omsai@xm2:/tmp/repo-local$ git remote add origin /tmp/repo-remote omsai@xm2:/tmp/repo-local$ mkdir /tmp/repo-remote omsai@xm2:/tmp/repo-local$ git -C /tmp/repo-remote init --bare Initialized empty Git repository in /tmp/repo-remote/ omsai@xm2:/tmp/repo-local$ git push fatal: The current branch master has no upstream branch. To push the current branch and set the remote as upstream, use git push --set-upstream origin master omsai@xm2:/tmp/repo-local$ git push origin master Enumerating objects: 3, done. Counting objects: 100% (3/3), done. Writing objects: 100% (3/3), 217 bytes | 217.00 KiB/s, done. Total 3 (delta 0), reused 0 (delta 0) To /tmp/repo-remote * [new branch] master -> master omsai@xm2:/tmp/repo-local$
Talking about "origin master" does not add much cognitive load. You should have already explained what "master" is when you explain the first commit message, and origin is the name we gave to the remote URL:
omsai@xm2:/tmp/repo-local$ git remote -v origin /tmp/repo-remote (fetch) origin /tmp/repo-remote (push) omsai@xm2:/tmp/repo-local$
Thanks for your comment @omsai, much appreciated. You're absolutely right of course, I neglected the case of pushing an existing local to a bare remote, that does complicate things.
Having said that, I'm a little bit convinced, but not fully convinced (yet?).
The most likely scenario I see for a bare repo is a new repo on services like github, bitbucket etc - but they're pretty good at being explicit about how to upload existing (and new) code. I just don't see this as a major stumbling block.
Otherwise users might create a bare repo themselves (using commands we haven't taught them), or someone else creates it for them, or they start messing around with remotes. But to my mind these are all beyond the scope of the material.
I suspect there are other cases that I'm forgetting, but I can't think of anything else right now? Are there other important cases I've overlooked here?
As to the comment
I'm interested in the opinion of the community here, because this is different to my experience. I've not found master trivial to deal with without the concept of a branch. I certainly haven't got a foolproof sentence or two to introduce it, I would be interested if anyone else does. If this can be done, it would benefit from being in the notes.
Same goes for explaining origin without multiple remote, but I find this one easier to avoid explaining.