Skip to main content
10 of 13
Making the more-useful-to-almost-everybody answer much more obvious
Leopd
  • 42.3k
  • 31
  • 133
  • 172

N.B. If you simply want to move a branch to another commit, the easiest way is

git branch -f branch-name new-tip-commit

as detailed by Chris Johnsen.

You can do it for arbitrary refs. This is how to move a branch pointer:

git update-ref -m "reset: Reset <branch> to <new commit>" refs/heads/<branch> <commit>

The general form:

git update-ref -m "reset: Reset <branch> to <new commit>" <ref> <commit>

You can pick nits about the reflog message if you like - I believe the branch -f one is different from the reset --hard one, and this isn't exactly either of them.

Adam A
  • 14.6k
  • 6
  • 32
  • 41