Remarque: Vous ne devez pas rebase commits qui ont été poussés à un autre repo.
git log --oneline -4
D commit_message_for_D
C commit_message_for_C
B commit_message_for_B
A commit_message_for_A
git rebase --interactive
pick D commit_message_for_D
pick C commit_message_for_C
pick B commit_message_for_B
pick A commit_message_for_A
Type i
(Mettre VIM en mode insertion)
Modifier la liste ressemble à ceci (Vous n'avez pas à supprimer ou d'inclure le message de commit):
pick C commit_message_for_C
pick B commit_message_for_B
pick A commit_message_for_A
squash D
Type Esc , puis ZZ
(Enregistrer et quitter VIM)
# This is a combination of 2 commits.
# The first commit's message is:
commit_message_for_D
# This is the 2nd commit message:
commit_message_for_A
Type i
Le changement qu'elle ressemble à ceci:
new_commit_message_for_A_and_D
Type Esc , puis ZZ
git log --oneline -4
E new_commit_message_for_A_and_D
C commit_message_for_C
B commit_message_for_B
git show E
(You should see a diff showing a combination of changes from A and D)