How can I combine 2 'git commit

I made 2 'git commit' locally. But I didn’t click, is it possible to edit my git and merge those 2 git commit into 1?

+5
source share
3 answers

Yes, it is possible:

You must first find a commit that is in front of the ones you want to work with. Imagine we want to combine the last two commits:

git rebase -i HEAD~3

This will launch the editor for interactive forwarding, which will give you the opportunity to perform the so-called crushing of commits, and it will list the commits starting from the moment when three months ago.

, , , . , ! - , "s" ()

, , . git - " ". , , . , , .

+11

, git commit --amend, . , git rebaling then:

git checkout --soft HEAD~

,

git commit --amend -C HEAD

. -C HEAD , .

+4

All Articles