lab 32 Resetting the Greet Branch

Goals

Reset the greet branch 01

Let’s go back in time on the greet branch to the point before we merged master onto it. We can reset a branch to any commit we want. Essentially this is modifying the branch pointer to point to anywhere in the commit tree.

In this case we want to back greet up to the point prior to the merge with master. We need to find the last commit before the merge.

Execute:

git checkout saluer
git hist

Output:

$ git checkout saluer
Switched to branch 'saluer'
$ git hist
*   83299eb 2014-02-21 | Merge branch 'master' into saluer (HEAD, saluer) [Jim Weirich]
|\  
| * 5c4b651 2014-02-21 | Ajout d'un README [Jim Weirich]
* | 83b5dc6 2014-02-21 | Rakefile mis à jour [Jim Weirich]
* | 0560857 2014-02-21 | bonjour utiliser Faireunsalut [Jim Weirich]
* | 1e570bd 2014-02-21 | Ajout de la classe Faireunsalut [Jim Weirich]
|/  
* 6f69f38 2014-02-21 | Ajout d'un Rakefile [Jim Weirich]
* c8d6b61 2014-02-21 | Déplacement de bonjour.rb dans lib [Jim Weirich]
* 83558be 2014-02-21 | Add an author/email comment [Jim Weirich]
* a9c6007 2014-02-21 | Ajout d'un commentaire (v1) [Jim Weirich]
* 221243e 2014-02-21 | Ajouter une valeur par défaut (v1-beta) [Jim Weirich]
* 80fc666 2014-02-21 | Using ARGV [Jim Weirich]
* 834ca4f 2014-02-21 | Mon premier commit [Jim Weirich]

That’s a bit hard to read, but looking at the data we see that the “Updated Rakefile” commit was the last commit on the greet branch before merging. Let’s reset the greet branch to that commit.

Execute:

git reset --hard <hash>

Output:

$ git reset --hard 83b5dc6
HEAD is now at 83b5dc6 Rakefile mis à jour

Check the branch. 02

Look at the log for the greet branch. We no longer have the merge commits in its history.

Execute:

git hist --all

Output:

$ git hist --all
* ee34d83 2014-02-21 | La fusion depuis master corrige le conflit (master) [Jim Weirich]
* 4075c2b 2014-02-21 | Rendre interactif [Jim Weirich]
* 5c4b651 2014-02-21 | Ajout d'un README [Jim Weirich]
| * 83b5dc6 2014-02-21 | Rakefile mis à jour (HEAD, saluer) [Jim Weirich]
| * 0560857 2014-02-21 | bonjour utiliser Faireunsalut [Jim Weirich]
| * 1e570bd 2014-02-21 | Ajout de la classe Faireunsalut [Jim Weirich]
|/  
* 6f69f38 2014-02-21 | Ajout d'un Rakefile [Jim Weirich]
* c8d6b61 2014-02-21 | Déplacement de bonjour.rb dans lib [Jim Weirich]
* 83558be 2014-02-21 | Add an author/email comment [Jim Weirich]
* a9c6007 2014-02-21 | Ajout d'un commentaire (v1) [Jim Weirich]
* 221243e 2014-02-21 | Ajouter une valeur par défaut (v1-beta) [Jim Weirich]
* 80fc666 2014-02-21 | Using ARGV [Jim Weirich]
* 834ca4f 2014-02-21 | Mon premier commit [Jim Weirich]

Table des matières