lab 32 Resetting the Greet Branch

Goals

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
*   74bdfbd 2013-10-06 | Merged master fixed conflict. (HEAD, greet) [Ismail Dhorat]
|\  
| * 2957100 2013-10-06 | Made interactive (master) [Ismail Dhorat]
* |   4ce379e 2013-10-06 | Merge branch 'master' into greet [Ismail Dhorat]
|\ \  
| |/  
| * 313c04d 2013-10-06 | Added README [Ismail Dhorat]
* | 7a5c511 2013-10-06 | Updated Rakefile [Ismail Dhorat]
* | 815cf27 2013-10-06 | Hello uses Greeter [Ismail Dhorat]
* | 209ff42 2013-10-06 | Added greeter class [Ismail Dhorat]
|/  
* b3e19a3 2013-10-06 | Added a Rakefile. [Ismail Dhorat]
* 14f09c0 2013-10-06 | Moved hello.rb to lib [Ismail Dhorat]
* 1fed2ec 2013-10-06 | Add an author/email comment [Ismail Dhorat]
* dc44f2e 2013-10-06 | Added a comment (v1) [Ismail Dhorat]
* 5ec54fd 2013-10-06 | Added a default value (v1-beta) [Ismail Dhorat]
* e606a20 2013-10-06 | Using ARGV [Ismail Dhorat]
* 5d95e74 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 7a5c511
HEAD is now at 7a5c511 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
* 7a5c511 2013-10-06 | Updated Rakefile (HEAD, greet) [Ismail Dhorat]
* 815cf27 2013-10-06 | Hello uses Greeter [Ismail Dhorat]
* 209ff42 2013-10-06 | Added greeter class [Ismail Dhorat]
| * 2957100 2013-10-06 | Made interactive (master) [Ismail Dhorat]
| * 313c04d 2013-10-06 | Added README [Ismail Dhorat]
|/  
* b3e19a3 2013-10-06 | Added a Rakefile. [Ismail Dhorat]
* 14f09c0 2013-10-06 | Moved hello.rb to lib [Ismail Dhorat]
* 1fed2ec 2013-10-06 | Add an author/email comment [Ismail Dhorat]
* dc44f2e 2013-10-06 | Added a comment (v1) [Ismail Dhorat]
* 5ec54fd 2013-10-06 | Added a default value (v1-beta) [Ismail Dhorat]
* e606a20 2013-10-06 | Using ARGV [Ismail Dhorat]
* 5d95e74 2013-10-06 | First Commit [Ismail Dhorat]

Table of Contents