33. Reset of the Master branch

Goals

  • Reset the master branch to the point prior to the conflicting commit.

01 Resetting the master branch

The interactive mode we added to the master branch has become a change conflicting with the changes in the style branch. Let’s revert the changes in the master branch up to the point before the conflict change was made. This allows us to demonstrate the rebase command without having to worry about conflicts.

Run:

git checkout master
git hist

Result:

$ git hist
* 454ec68 2011-03-09 | Life is great! (HEAD, master) [Marina Pushkova]
* 6c0f848 2011-03-09 | Added README [Marina Pushkova]
* 8029c07 2011-03-09 | Added index.html. [Marina Pushkova]
* 567948a 2011-03-09 | Moved hello.html to lib [Marina Pushkova]
* 6a78635 2011-03-09 | Add an author/email comment [Marina Pushkova]
* fa3c141 2011-03-09 | Added HTML header (v1) [Marina Pushkova]
* 8c32287 2011-03-09 | Added standard HTML page tags (v1-beta) [Marina Pushkova]
* 43628f7 2011-03-09 | Added h1 tag [Marina Pushkova]
* 911e8c9 2011-03-09 | First Commit [Marina Pushkova]

The "Added README" commit goes directly before the conflicting interactive mode we added. Right now we need to reset the master branch to the "Added README" branch.

Run:

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

Examine the log. It should look as if we rewound the repository to a point in time, prior to any mergers.

Result:

$ git reset --hard 6c0f848
$ git hist --all
* 6c0f848 2011-03-09 | Added README (HEAD, master) [Marina Pushkova]
| * 07a2a46 2011-03-09 | Updated index.html (style) [Marina Pushkova]
| * 649d26c 2011-03-09 | Hello uses style.css [Marina Pushkova]
| * 1f3cbd2 2011-03-09 | Added css stylesheet [Marina Pushkova]
|/  
* 8029c07 2011-03-09 | Added index.html. [Marina Pushkova]
* 567948a 2011-03-09 | Moved hello.html to lib [Marina Pushkova]
* 6a78635 2011-03-09 | Add an author/email comment [Marina Pushkova]
* fa3c141 2011-03-09 | Added HTML header (v1) [Marina Pushkova]
* 8c32287 2011-03-09 | Added standard HTML page tags (v1-beta) [Marina Pushkova]
* 43628f7 2011-03-09 | Added h1 tag [Marina Pushkova]
* 911e8c9 2011-03-09 | First Commit [Marina Pushkova]
SVN?
© 2011-2014 Git How To. All rights reserved / Contact us