32. Resetting the style branch

Goals

  • Resetting the branch style to the point prior to the first merge.

01 Resetting the style branch

Let us go on style branch to the point before we merged it with master branch. We can reset branch to any commit. In fact, this changes branch pointer to point at any commit in the tree.

Here, we want to come back in style branch to a point before merging with the master. We have to find the last commit prior the merge.

Run:

git checkout style
git hist

Result:

$ git checkout style
Already on 'style'
$ git hist
*   645c4e6 2011-03-09 | Merged master fixed conflict. (HEAD, style) [Marina Pushkova]
|\  
| * 454ec68 2011-03-09 | Life is great! (master) [Marina Pushkova]
* |   5813a3f 2011-03-09 | Merge branch 'master' into style [Marina Pushkova]
|\ \  
| |/  
| * 6c0f848 2011-03-09 | Added README [Marina Pushkova]
* | 07a2a46 2011-03-09 | Updated index.html [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]

It's a little hard to read, but we can see from the data that Updated index.html commit was the latest on the style branch prior merging. Let us reset the style branch to this commit.

Run:

git reset --hard <hash>

Result:

$ git reset --hard 07a2a46
HEAD is now at 07a2a46 Updated index.html

02 Check the branch.

Look for the style branch log. There are no merge commits In our history.

Run:

git hist --all

Result:

$ git hist --all
* 454ec68 2011-03-09 | Life is great! (master) [Marina Pushkova]
* 6c0f848 2011-03-09 | Added README [Marina Pushkova]
| * 07a2a46 2011-03-09 | Updated index.html (HEAD, 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