Reputation: 1480
my initial graph looked like this:
* 73f91fd (HEAD -> master) third change
* 9ced830 second change
* 026632e first change
* 5a12d08 second recipe for guacamole
* 7777ef7 (origin/master, origin/HEAD) Merged in fork/gitcourse (pull request #2)
then, I applied the following command to reset the commit history:
git reset --soft 7777ef7
but later, I realized that the commit 73f91fd was the correct one and I wanted to revert the history and I typed:
git reset 73f91fd
in this case, I ended up with the following graph:
* 73f91fd (HEAD) third change
* 9ced830 second change
* 026632e first change
* 5a12d08 second recipe for guacamole
* 7777ef7 (origin/master, origin/HEAD, master) Merged in fork/gitcourse (pull request #2)
git status
tells me that HEAD is detached which is correct. What I don't know is how I can move the master branch forward to be synchronized with the HEAD.
Any comment is welcome, thanks.
Upvotes: 1
Views: 38
Reputation: 22057
git checkout
has an option for this : -B
git checkout -B master 73f91fd
will checkout said commit while also setting master
on it.
Upvotes: 1
Reputation: 52151
Run :
# forcibly set 'master' to your current commit
git branch -f master
# set 'master' as the active branch
git checkout master
Upvotes: 0