lab 32 Resetting the Greet Branch
Goals
- Reset the greet branch to the point before the first merge.
Reset the greet branch 01
Let’s go back in time on the greet branch to the point before we merged master onto it. We can reset a branch to any commit we want. Essentially this is modifying the branch pointer to point to anywhere in the commit tree.
In this case we want to back greet up to the point prior to the merge with master. We need to find the last commit before the merge.
Execute:
git checkout greet git hist
Output:
$ git checkout greet Already on 'greet' $ git hist * 084a3a1 2013-10-06 | Merged master fixed conflict. (HEAD, greet) [Ismail Dhorat] |\ | * 736de04 2013-10-06 | Made interactive (master) [Ismail Dhorat] * | d1c6a6d 2013-10-06 | Merge branch 'master' into greet [Ismail Dhorat] |\ \ | |/ | * cad8e98 2013-10-06 | Added README [Ismail Dhorat] * | 6e84bb4 2013-10-06 | Updated Rakefile [Ismail Dhorat] * | b90deb7 2013-10-06 | Hello uses Greeter [Ismail Dhorat] * | 0a6c49b 2013-10-06 | Added greeter class [Ismail Dhorat] |/ * 27b8b27 2013-10-06 | Added a Rakefile. [Ismail Dhorat] * 23944f0 2013-10-06 | Moved hello.rb to lib [Ismail Dhorat] * 273edac 2013-10-06 | Add an author/email comment [Ismail Dhorat] * 9efd33e 2013-10-06 | Added a comment (v1) [Ismail Dhorat] * 8b9a1c6 2013-10-06 | Added a default value (v1-beta) [Ismail Dhorat] * f6f4d6b 2013-10-06 | Using ARGV [Ismail Dhorat] * f98d857 2013-10-06 | First Commit [Ismail Dhorat]
That’s a bit hard to read, but looking at the data we see that the “Updated Rakefile” commit was the last commit on the greet branch before merging. Let’s reset the greet branch to that commit.
Execute:
git reset --hard <hash>
Output:
$ git reset --hard 6e84bb4 HEAD is now at 6e84bb4 Updated Rakefile
Check the branch. 02
Look at the log for the greet branch. We no longer have the merge commits in its history.
Execute:
git hist --all
Output:
$ git hist --all * 6e84bb4 2013-10-06 | Updated Rakefile (HEAD, greet) [Ismail Dhorat] * b90deb7 2013-10-06 | Hello uses Greeter [Ismail Dhorat] * 0a6c49b 2013-10-06 | Added greeter class [Ismail Dhorat] | * 736de04 2013-10-06 | Made interactive (master) [Ismail Dhorat] | * cad8e98 2013-10-06 | Added README [Ismail Dhorat] |/ * 27b8b27 2013-10-06 | Added a Rakefile. [Ismail Dhorat] * 23944f0 2013-10-06 | Moved hello.rb to lib [Ismail Dhorat] * 273edac 2013-10-06 | Add an author/email comment [Ismail Dhorat] * 9efd33e 2013-10-06 | Added a comment (v1) [Ismail Dhorat] * 8b9a1c6 2013-10-06 | Added a default value (v1-beta) [Ismail Dhorat] * f6f4d6b 2013-10-06 | Using ARGV [Ismail Dhorat] * f98d857 2013-10-06 | First Commit [Ismail Dhorat]