Move branch pointer to different commit without checkout

Mot picture Mot · Mar 29, 2011 · Viewed 377.4k times · Source

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 tracked remote branch)?

Answer

Chris Johnsen picture Chris Johnsen · Mar 29, 2011
git branch -f <branch-name> [<new-tip-commit>]

If new-tip-commit is omitted it defaults to the current commit.