Is there a proper way to combine two commits that are out of order?

I want to combine two commits that are out of order.

For example, if I execute the command git rebase -i HEAD~3:

pick 8h47n1f Update documentation and release-notes  #a
pick 8n32b7a Implemented some random function        #b
pick a73ncj1 Update documentation and release-notes  #c

I want to combine the lines a and c into one commit before pushing.

My current way to accomplish this is to reorder my commits as follows:

pick 8h47n1f Update documentation and release-notes   #a
squash a73ncj1 Update documentation and release-notes #c
pick 8n32b7a Implemented some random function         #b

So far, I have not seen any dangerous side effects. Does anyone know if I can really break something by doing this? Is there a better, safer way to do what I'm trying to accomplish?

+4
source share
2 answers

( afaik - ) . , (, ).

+3

, (git rebase -i), script . , . Git .

: . git-rebase :

--autosquash
--no-autosquash

"squash!..." ( "fixup!..." ), , ..., -reboot -i , , , , pick squash ( fixup). "fixup!" "squash!" , / git commit --fixup/--squash.

--interactive.

--autosquash rebase.autoSquash, .

commit c git commit --squash <commit-a> ( --amend, ). git rebase -i ( rebase.autoSquash), , .

, , -p -i. , git-rebase docs :

, --preserve-merges --interactive, . , , , .

+2

Source: https://habr.com/ru/post/1655534/


All Articles