In Git, how can I reorder (change) pushed commits?

I have a repository with one branch ( master):

a > b > e > f > g > c > d

It turns out I need changes in cand d(there are still two entries until the end of the story), so Id have:

a > b > c > d > e > f > g

Everyone pushed. I understand that I should not reinstall the exact commits, so what can I do?

+4
source share
2 answers

Here's a quick and dirty solution that doesn't change the story:

  • Use git revertto remove each commit from a branch.
  • Use git cherry-pickto reapply commits in the order you want.

. , .

+4

git push -f. , . , git rebase -i <hash of a>, , , git push -f.

+3

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


All Articles