lab 33 Resetting the Master Branch
Goals
- Reset the master branch to the point before the conflicting commit.
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 * 05f32c0 2013-04-13 | Made interactive (HEAD, master) [Jim Weirich] * b59a8c2 2013-04-13 | Added README [Jim Weirich] * 96ee164 2013-04-13 | Added a Rakefile. [Jim Weirich] * 0f36766 2013-04-13 | Moved hello.rb to lib [Jim Weirich] * eb30103 2013-04-13 | Add an author/email comment [Jim Weirich] * 1f7ec5e 2013-04-13 | Added a comment (v1) [Jim Weirich] * 582495a 2013-04-13 | Added a default value (v1-beta) [Jim Weirich] * 323e28d 2013-04-13 | Using ARGV [Jim Weirich] * 9416416 2013-04-13 | 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 * b59a8c2 2013-04-13 | Added README (HEAD, master) [Jim Weirich] | * 28917a4 2013-04-13 | Updated Rakefile (greet) [Jim Weirich] | * 4dac415 2013-04-13 | Hello uses Greeter [Jim Weirich] | * 39347b3 2013-04-13 | Added greeter class [Jim Weirich] |/ * 96ee164 2013-04-13 | Added a Rakefile. [Jim Weirich] * 0f36766 2013-04-13 | Moved hello.rb to lib [Jim Weirich] * eb30103 2013-04-13 | Add an author/email comment [Jim Weirich] * 1f7ec5e 2013-04-13 | Added a comment (v1) [Jim Weirich] * 582495a 2013-04-13 | Added a default value (v1-beta) [Jim Weirich] * 323e28d 2013-04-13 | Using ARGV [Jim Weirich] * 9416416 2013-04-13 | First Commit [Jim Weirich]