0

I am working with localizations, a process of iterating over 40 branches, implementing approximately 40 commits on each. Some of them (let's say half), are exactly the same for almost all branches. So I started copying the commit ID (like 085cfefc9291b) into a notepad, and then I cherry-pick from that list, when I want those changes implemented on my current branch.

My list of commits for cherry-pick (ex. git cherry-pick 290d953c2837):

  • 290d953c2837 --> update of product matrix (2017-02),
  • 9ee8c001165e6 --> Jsonify of outcomes and benefits (2017-02)
  • 13156cee10d --> implement dual backend/frontend of product range
  • 80c98c492 --> toggle backend filtration
  • 15106bdc --> include Oval in package (fusion2)
  • 085cfefc9291b --> exclude product range from frontend

These commits are from different branches of the same repository.

Something that would really fit my workflow perfectly, would be a way to bundle / squash these commits together into one commit. This would enable me to dynamically create patches along the way, and if I keep the long list of individual commmits, I could easily create different versions of the patches, some with more commits in them, some with less.

Which best practices do you know about for this?

1 Answers1

0
  1. Create a branch from a proper commit.
  2. Apply a subset of commits onto that branch.
  3. Squash those changes into one commit.

Suppose you have a set of commits {A,B,C,D,E,F,G} and a base commit Z. The process to squash A B C F would be like:

#create a branch patch1 from Z
git checkout -b patch1 Z
#apply A B C F
git cherry-pick A B C F
#squash them into one commit
git reset Z --soft
git commit -m 'squash A B C F'
#create a patch of the new commit if necessary
git format-patch -1

It's just one of the possible methods to create such a combined commit. And it's a bit hard to decide which commit could be the proper base.

Another method:

#create a branch patch1 from G
git branch patch1 G
#rebase and squash A B C F onto Z
git rebase -i --onto Z A^..patch1
#in the editor
  pick A
  squash B
  squash C
  squash F
#create a patch of the new commit if necessary
git format-patch -1
ElpieKay
  • 27,194
  • 6
  • 32
  • 53