3 ms·
Because they are referring to different things. `mybranch` is a reference in your local repository. `origin/mybranch` is a reference on a remote repository that
by qsantos 3y ago
Because they are referring to different things. `mybranch` is a reference in your local repository. `origin/mybranch` is a reference on a remote repository that you call `origin`, `origin/mybranch` is just a representation of this remote reference for convenience.
So, if we take the example from derefr [1], `git chekcout foo` lets you go to your own local branch `foo`. Then, `git reset --hard origin/foo` modifies the current local ref (`foo`) to be the same as `origin/foo`, and change the working directory accordingly.
[1] https://news.ycombinator.com/item?id=38118475 https://news.ycombinator.com/item?id=38118475
- permo-w 3y agoperhaps I'm misunderstanding, but this doesn't read so much as why as it does a rephrasing of the problem with an example
- mangodrunk 3y agoThat tends to happen a lot with git and other fads in the tech industry. See the discussion here where people are defending how git has the misleading message of “ Your branch is up to date with origin/master.” A lot of rationalizations working backwards.
- iamcreasy 3y agoDoes 'origin/mybranch' is referring to the local copy of the remote branch? Why can I run 'git checkout origin/mybranch'(which results in a detached head) but not 'git switch origin/mybranch'? Also git reset appears to be taking a commit as the final parameter, git reset [--soft | --mixed [-N] | --hard | --merge | --keep] [-q] [<commit>] But why it is accepting `origin/mybranch`. I am mostly rambling - feel free to ignore me.