Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

github

I have a repository with a single (master) branch:

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

It turns out that I need the changes in c and d (two commits toward the end of the history so far) to occur earlier, so that I’d have:

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

Everything’s been pushed. I understand I’m not supposed to rebase pushed commits, so what can I do?

like image 706
Ben Klein Avatar asked Sep 29 '15 20:09

Ben Klein


1 Answers

You cannot reorder pushed commits without git push -f. If this repository is shared between you and other guys, then you shouldn't do anything. If this is your own repo or it's on your own branch, use git rebase -i <hash of a>, then reorder the commits as you want, then git push -f.

like image 161
Xhacker Liu Avatar answered Nov 15 '22 09:11

Xhacker Liu