git squash.
Dans certain projet communautaire, il vous sera demandé de faire un git squash afin de réunir un ensemble de commit en un seul.
Voici la marche à suivre :
git squash -i HEAD~[NOMBRE DE COMMIT A MODIFIER]
Ensuite la console doit vous afficher quelques chose du genre :
$ git rebase -i HEAD~4
pick 01d1124 Adding license
pick 6340aaa Moving license into its own file
pick ebfd367 Jekyll has become self-aware.
pick 30e0ccb Changed the tagline in the binary, too.
# Rebase 60709da..30e0ccb onto 60709da
#
# Commands:
# p, pick = use commit
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
#
# If you remove a line here THAT COMMIT WILL BE LOST.
# However, if you remove everything, the rebase will be aborted.
#
Ici le commit 01d1124 est notre plus vieux commit et le 60709da doit correspondre au commit précédent nos modifications. Si nous voulons réunir les 3 commits suivants le 01d1124 ainsi que lui-même dans un nouveau commit unique il faudra modifier cette affichage comme ceci :
$ git rebase -i HEAD~4
pick 01d1124 Adding license
squash 6340aaa Moving license into its own file
squash ebfd367 Jekyll has become self-aware.
squash 30e0ccb Changed the tagline in the binary, too.
# Rebase 60709da..30e0ccb onto 60709da
#
# Commands:
# p, pick = use commit
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
#
# If you remove a line here THAT COMMIT WILL BE LOST.
# However, if you remove everything, the rebase will be aborted.
#
Une fois ces modifications effectuées vous devez enregistrer votre document et quitter (pour vi :w puis :q ou :wq)
La console va vous afficher la chose suivante :
# This is a combination of 4 commits.
# The first commit's message is:
Adding license
# This is the 2nd commit message:
Moving license into its own file
# This is the 3rd commit message:
Jekyll has become self-aware.
# This is the 4th commit message:
Changed the tagline in the binary, too.
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# Explicit paths specified without -i nor -o; assuming --only paths...
# Not currently on any branch.
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# new file: LICENSE
# modified: README.textile
# modified: Rakefile
# modified: bin/jekyll
#
Vous pouvez par exemple remanier le commentaire comme ceci :
# This is a combination of 4 commits.
# The first commit's message is:
Adding license
Moving license into its own file
Jekyll has become self-aware.
Changed the tagline in the binary, too.
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# Explicit paths specified without -i nor -o; assuming --only paths...
# Not currently on any branch.
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# new file: LICENSE
# modified: README.textile
# modified: Rakefile
# modified: bin/jekyll
#
Voila notre squash est prêt à être utilisé !
Il ne manque plus qu'a le push sur notre branch:
git push --force origin fix-test
Le force est obligatoire ;)
Merci à Laurent Baey pour son aide.