Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git rebase -i for specific commits?

Tags:

git

git-rebase

I have a branch with a few commits I'd like to interactively rebase. However, after pulling and merging there are now other commits interleaved with mine so I can't just do something like git rebase -i HEAD~3

Is it possible to do an interactive rebase while choosing individual commits? Something like git rebase -i 23duirs 3eujsfe ...

Another possibility-- If I simply run git rebase -i I believe it's possible to cut and paste my commit lines to be consecutive, and squash from there, is that correct? Is there a best practice for doing so, to minimize the chance of conflicts with the unrelated commits in there?

like image 266
jkj2000 Avatar asked Sep 16 '15 16:09

jkj2000


1 Answers

Given this

pick <unrelated a>
pick A
pick <unrelated b>
pick B
pick <unrelated c>

you can definitely do

pick <unrelated a>
pick <unrelated b>
pick <unrelated c>
pick A
squash B

Provided that your commit are really unrelated to the other changes, this will work just fine.

like image 81
Gabriele Petronella Avatar answered Sep 22 '22 06:09

Gabriele Petronella