Skip to content

lab 33 Resetting the Master Branch

Goals

Reset the master branch

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
* fabda38 2019-11-01 | Made interactive (HEAD -> master) [Jim Weirich]
* 099ccd0 2019-11-01 | Added README [Jim Weirich]
* ed35144 2019-11-01 | Added a Rakefile. [Jim Weirich]
* 4421854 2019-11-01 | Moved hello.rb to lib [Jim Weirich]
* 185fc95 2019-11-01 | Add an author/email comment [Jim Weirich]
* 4d578d4 2019-11-01 | Added a comment (tag: v1) [Jim Weirich]
* dc1d42f 2019-11-01 | Added a default value (tag: v1-beta) [Jim Weirich]
* 9a1c494 2019-11-01 | Using ARGV [Jim Weirich]
* 063b40e 2019-11-01 | 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’ commit.

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
* 69a8d70 2019-11-01 | Updated Rakefile (greet) [Jim Weirich]
* 7b8b268 2019-11-01 | Hello uses Greeter [Jim Weirich]
* f84663f 2019-11-01 | Added greeter class [Jim Weirich]
| * 099ccd0 2019-11-01 | Added README (HEAD -> master) [Jim Weirich]
|/  
* ed35144 2019-11-01 | Added a Rakefile. [Jim Weirich]
* 4421854 2019-11-01 | Moved hello.rb to lib [Jim Weirich]
* 185fc95 2019-11-01 | Add an author/email comment [Jim Weirich]
* 4d578d4 2019-11-01 | Added a comment (tag: v1) [Jim Weirich]
* dc1d42f 2019-11-01 | Added a default value (tag: v1-beta) [Jim Weirich]
* 9a1c494 2019-11-01 | Using ARGV [Jim Weirich]
* 063b40e 2019-11-01 | First Commit [Jim Weirich]