1

I have a branch x that was already pushed because there are more of us working on that feature. Now I would like to to rebase it on top of master and squash some commits.

My current workflow is:

git co x
git format-patch HEAD~28
git co master
git am 00*.patch
git rebase -i HEAD~28
git push
git push origin :x

I am pretty sure is much better workflow available. Because it is a git. Help, thanks.

Okay I found a solution using cherry-pick with a range:

git cherry-pick XXX..YYY

Feel free to add additional solutions, will upvote them all when appropriate ;-)

lzap
  • 16,417
  • 12
  • 71
  • 108
  • Maybe it can helps you ? http://stackoverflow.com/questions/5667884/how-to-squash-commits-in-git-after-they-have-been-pushed – Sandro Munda Feb 27 '12 at 09:24
  • Well, I dont want to force pushing it. I want to put it on top of my master branch and then delete the "x" branch. But thanks! – lzap Feb 27 '12 at 09:54
  • Can you please spell out the `...`s? I suspect the 4 commands (format-patch_co+am+rebase) can be done with just one rebase or merge with appropriate arguments, but I can't tell for sure without those arguments. – Jan Hudec Feb 27 '12 at 10:16
  • +Jan Hudec - edited. Those are pseudo commands, but it should work I hope. Thanks! – lzap Feb 27 '12 at 11:11
  • Got an idea of something like: git rebase --onto a b f – lzap Feb 27 '12 at 11:49
  • Git cherry-pick B..A worked! Then I did rebase. Okay. Solved. – lzap Feb 27 '12 at 12:28
  • Note that rebasing stuff that has been shared is often frowned upon, since you are rewriting history that others have based their commits on. – rtn Feb 27 '12 at 13:47

0 Answers0