I would do a hard reset as in @SpoonMeiser's answer, but I wouldn't do a hard reset of the reflog. The reflog is special - we might need to consult it but we shouldn't need to reset to it in everyday git use.
Instead, I would find the last commit of your branch before you pulled, and do:
git reset --hard 46c80011b9845548000f8ed2178755d28c5e6832
or whatever the hash is.
You should be able to find the hash by doing git log
. If the pull performed a merge, the most recent commit will be a merge. The output of git log looks like this:
commit eddb8b70c9167cf88653d7649f054c0d69a5ee8a
Merge: a89faff 980a815
Author: jwg <jwg@example.com>
Date: Wed Mar 15 10:22:16 2017 +0000
Merge branch 'some_random_remote_branch' of git_server:foo/bar into my_precious_local_branch
The second line shows the two commits which were merged. One of these is the remote branch, one is my_precious_local_branch
, you should be able to find out which.
If the last commit isn't a merge commit, then the pull was a fast-forward. This means that your local branch didn't have anything on it which wasn't on the remote branch. However, you might still want your local branch back. You can go through git log
and decide exactly which commit you want to restore, then do git reset --hard
to it.