Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to squash my changes into a single result commit and pick into master branch?

Tags:

git

Let's suppose I need to perform some average-length (several days) refactoring.

I create "mybranch" from master, do the work, sometimes I perform merges from master to mybranch (some other team members supposed to continue the work, and probably I'll need to get their changes). And after a while I'm ready to merge my changes back to master.

Will I be able to squash only my changes (excluding the changesets with merges from master, since they aren't mine) and cherry-pick a single result commit of my works into the master? Is it a possible to do scenario?

like image 660
zerkms Avatar asked Aug 27 '11 06:08

zerkms


1 Answers

Yep. You can confirm it with a small test repository. Just do:

git rebase --interactive master mybranch

and choose squash for all the lines except the first. Then you just checkout master and do a regular fast-forward merge of mybranch.

like image 191
Karl Bielefeldt Avatar answered Sep 28 '22 17:09

Karl Bielefeldt