1

I created multiple commit in git with multiple comment, i wonder is it possible to make multiple commit into single commit in git, if yes what command we usually use ?

pick xxx1 msg1
pick xxx2 msg2
pick xxx3 msg4
pick xxx5 msg5
pick xxx6 msg6

i want to change it into 1 commit with 1 comment only

  • Possible duplicate of [How to use git merge --squash?](https://stackoverflow.com/questions/5308816/how-to-use-git-merge-squash) – Aurélien B Nov 06 '18 at 10:38
  • Possible duplicate of [git squashing multiple commits into multiple commits](https://stackoverflow.com/questions/14146647/git-squashing-multiple-commits-into-multiple-commits) – phd Nov 06 '18 at 13:41
  • https://stackoverflow.com/search?q=%5Bgit%5D+squash+multiple+commits – phd Nov 06 '18 at 13:41

2 Answers2

1

Use squash or fixup to meld commits together. Fixup throws away the commit message and adds the changes to the previous commit, squash concatenates the messages.

choroba
  • 231,213
  • 25
  • 204
  • 289
0

Let's say your commit history looks like:

X <- A <- B <- C <- D(master)

You want to make A, B, C, D into only one commit Y, like this:

X <- Y(master)

Make sure you are in a clean state of working dir, then type:

git reset X

Now the history looks like:

X(master)

But your working dir is having the content of commit D.

Now you can finalize:

git add . -Av
git commit -m "just a big message"
Nghia Bui
  • 3,694
  • 14
  • 21