Move current branch HEAD to an arbitrary commit

suggest change

A branch is just a pointer to a commit, so you can freely move it around. To make it so that the branch is referring to the commit aabbcc, issue the command

git reset --hard aabbcc

--hard moves the current branch and also replaces the index and working tree, so uncommitted work is discarded. Commits that are no longer on the branch are still in the reflog until garbage collection. You might lose work with this command. If that’s the case, you can use the reflog to recover the lost commits. It can be advised to perform this command on a new branch instead of your current one.

However, this command can be particularly useful when rebasing or doing such other large history modifications.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents