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
* ee97f8e 2020-06-20 | Made interactive (HEAD -> master) [Jim Weirich]
* 8d90176 2020-06-20 | Added README [Jim Weirich]
* 5aec14d 2020-06-20 | Added a Rakefile. [Jim Weirich]
* 721b979 2020-06-20 | Moved hello.rb to lib [Jim Weirich]
* 907a445 2020-06-20 | Add an author/email comment [Jim Weirich]
* 4254c94 2020-06-20 | Added a comment (tag: v1) [Jim Weirich]
* c8b3af1 2020-06-20 | Added a default value (tag: v1-beta) [Jim Weirich]
* 30c2cd4 2020-06-20 | Using ARGV [Jim Weirich]
* 4445720 2020-06-20 | 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
* 8d90176 2020-06-20 | Added README (HEAD -> master) [Jim Weirich]
| * 228a31e 2020-06-20 | Updated Rakefile (greet) [Jim Weirich]
| * 98cfd8a 2020-06-20 | Hello uses Greeter [Jim Weirich]
| * cf0438b 2020-06-20 | Added greeter class [Jim Weirich]
|/  
* 5aec14d 2020-06-20 | Added a Rakefile. [Jim Weirich]
* 721b979 2020-06-20 | Moved hello.rb to lib [Jim Weirich]
* 907a445 2020-06-20 | Add an author/email comment [Jim Weirich]
* 4254c94 2020-06-20 | Added a comment (tag: v1) [Jim Weirich]
* c8b3af1 2020-06-20 | Added a default value (tag: v1-beta) [Jim Weirich]
* 30c2cd4 2020-06-20 | Using ARGV [Jim Weirich]
* 4445720 2020-06-20 | First Commit [Jim Weirich]