2

I've got a branch I want to merge into another via a squash commit. In some cases these new files have leading or trailing spaces that are not needed. If I remove the extra spaces during the squash merge how do I push those changes into the original branch without having to manually do the fixes again?

Currently I am applying the changes twice. Once when I squash merge into a testing branch. And again when I squash merge the original branch into master.

My workflow

git co staging
git merge origin/feature --squash
git push origin staging

Do my checking, and then follow up with

git co master
git merge origin/feature --squash
git push origin master
Cœur
  • 37,241
  • 25
  • 195
  • 267
Jason
  • 3,736
  • 5
  • 33
  • 40
  • Can you post the command sequence of what you're doing? It sounds like you're rebasing the same topic branch onto two different long term branches, likely generating different commit hashes along the way. If that's the case, this workflow will end badly. – Christopher Jul 27 '12 at 18:48
  • Why don't you fix whitespaces before merging? – Oleksandr Pryimak Jul 28 '12 at 02:04

1 Answers1

0

It would be better to have a pre-commit hook which removes those trailing whitespace first, which means any further merge wouldn't have any issue on that front.

See for instance "Make git automatically remove trailing whitespace before committing".


For you existing commit, you could you a git reset --soft, combined with a git commit --all --amend in order to apply that post-commit hook to your last commit on feature, before merging it to staging/master.

See "Practical uses of git reset --soft?".

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250