Why the / ?
In git push <remote> <branch>
you are giving two parameters: the remote name and the branch name. Hence no reason to add a /
. The remote
is an essential part here; after all, push
will communicate with it.
In git reset ... origin/my_branch
you are giving one parameter: the name of a branch. In this context, origin/my_branch
is the name of the branch, fully specified. You could also give the name of a local branch here (in which case you would leave off the .../
part. So if there were a space in between (instead of using the fully qualified branch name), it would become quite confusing and error prone. reset
does not care about or even know about remotes.
Careful
git reset --hard origin/my_branch
This needs a git checkout my_branch
first or you will reset whatever other branch you are currently on. You might want to edit your question so people who stumble across it don't get the wrong impression.
Keep their changes
More importantly, there is no need to do a hard reset (i.e. to throw away all locally committed changes on the branch) after a rebase was force-pushed. Your colleagues can simply do the same rebase operation on their end, and then everything is fine again (well, not in pathologigal cases with lots and lots of conflicts, of course). The "rerere cache" can help here (see git help rerere
).
So, if you did:
git checkout my_branch
git rebase abc12345
git push --force
Then they can do:
git fetch # in case they do not have abc12345 yet
git checkout my_branch
git rebase abc12345
git pull
The rebase operation is repeatable, so this should work well, usually. This will let the other developers keep all their local changes and get yours on top (remember that the pull
is basically a merge
).