lab 33 Resetting the Master Branch

Goals

Reset the master branch 01

When we added the interactive mode to the master branch, we made a change that conflicted with changes in the greet branch. Let’s rewind the master branch to a point before the conflicting change. This allows us to demonstrate the rebase command without worrying about conflicts.

Execute:

git checkout master
git hist

Output:

$ git hist
* 8697f14 2014-10-25 | Made interactive (HEAD, master) [Jim Weirich]
* 6fd9eff 2014-10-25 | Added README [Jim Weirich]
* 14ba469 2014-10-25 | Added a Rakefile. [Jim Weirich]
* 4b249b3 2014-10-25 | Moved hello.rb to lib [Jim Weirich]
* bfd1408 2014-10-25 | Add an author/email comment [Jim Weirich]
* a1189df 2014-10-25 | Added a comment (tag: v1) [Jim Weirich]
* 6083cb8 2014-10-25 | Added a default value (tag: v1-beta) [Jim Weirich]
* b24f3ff 2014-10-25 | Using ARGV [Jim Weirich]
* cf466b4 2014-10-25 | First Commit [Jim Weirich]

The ‘Added README’ commit is the one directly before the conflicting interactive mode. We will reset the master branch to ‘Added README’ branch.

Execute:

git reset --hard <hash>
git hist --all

Review the log. It should look like the repository has been wound back in time to the point before we merged anything.

Output:

$ git hist --all
* 12414e9 2014-10-25 | Updated Rakefile (greet) [Jim Weirich]
* 43ba308 2014-10-25 | Hello uses Greeter [Jim Weirich]
* acd8535 2014-10-25 | Added greeter class [Jim Weirich]
| * 6fd9eff 2014-10-25 | Added README (HEAD, master) [Jim Weirich]
|/  
* 14ba469 2014-10-25 | Added a Rakefile. [Jim Weirich]
* 4b249b3 2014-10-25 | Moved hello.rb to lib [Jim Weirich]
* bfd1408 2014-10-25 | Add an author/email comment [Jim Weirich]
* a1189df 2014-10-25 | Added a comment (tag: v1) [Jim Weirich]
* 6083cb8 2014-10-25 | Added a default value (tag: v1-beta) [Jim Weirich]
* b24f3ff 2014-10-25 | Using ARGV [Jim Weirich]
* cf466b4 2014-10-25 | First Commit [Jim Weirich]

Table of Contents