Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I combine two non-sequential git commits into one? [duplicate]

Tags:

If the following is a list of commits on a branch:

A - B - C - D

How can I combine commits A and C into (AC)?

(AC) - B - D
like image 575
titaniumdecoy Avatar asked Mar 19 '11 06:03

titaniumdecoy


People also ask

How do I merge commits together?

In case you are using the Tower Git client, using Interactive Rebase to squash some commits is very simple: just select the commits you want to combine, right-click any of them, and select the "Squash Revisions..." option from the contextual menu.


1 Answers

First do git rebase -i aaaaaa^ and then your text editor will show up looking like this:

pick aaaaaa pick bbbbbb pick cccccc pick dddddd 

Change it so that it looks like

pick aaaaaa squash cccccc pick bbbbbb pick dddddd 

and close it and git does the rest.

http://git-scm.com/docs/git-rebase

like image 156
Tyler Avatar answered Nov 04 '22 18:11

Tyler