Git pull into wrong branch
Reset the master branch:
git reset --hard origin/master
You can use git log
to find the SHA-1 of the revision you want to be at the head of your toolwork
branch, then use git reset --hard <SHA1>
to revert your working copy to that revision.
Back everything up first! And re-read the man page for git reset
to make sure it's doing what you want.
EDIT: Oh yes, ORIG_HEAD should contain the right SHA-1. But check first.
git reset --hard ORIG_HEAD
From the git reset
man page (if you just did the pull):
Undo a merge or pull
$ git pull (1)
Auto-merging nitfol
CONFLICT (content): Merge conflict in nitfol
Automatic merge failed; fix conflicts and then commit the result.
$ git reset --hard (2)
$ git pull . topic/branch (3)
Updating from 41223... to 13134...
Fast-forward
$ git reset --hard ORIG_HEAD (4)
- Try to update from the upstream resulted in a lot of conflicts; you were not ready to spend a lot of time merging right now, so you decide to do that later.
- "
pull
" has not made merge commit, so "git reset --hard
" which is a synonym for "git reset --hard HEAD
" clears the mess from the index file and the working tree.- Merge a topic branch into the current branch, which resulted in a fast-forward.
- But you decided that the topic branch is not ready for public consumption yet.
"pull" or "merge" always leaves the original tip of the current branch inORIG_HEAD
, so resetting hard to it brings your index file and the working tree back to that state, and resets the tip of the branch to that commit.
See HEAD
and ORIG_HEAD
for more.