Back
To move the branch pointer of a checked-out branch, one can use the git reset --hard command. But how to move the branch pointer of a not-checked out branch to point at a different commit (keeping all other stuff like a tracked remote branch)?
In case if you just want to move a branch to another commit:
$ git branch -f branch-name new-tip-commit
In order 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>
For more git commands, you can visit the git tutorial.
1.2k questions
2.7k answers
501 comments
693 users