When running git merge --squash the commit message contains the commit messages of all the commits I'm squashing, great.
However, for some reason it actually contains far more than just the commits I'm squashing.
Here is my workflow:
- Various feature branches merge, normally, into development.
- When a version is ready to go, I do a
git merge --squashfrom development into staging. - I do a second commit, in staging, with the version number, and then do a normal merge from staging back into development. (I occasionally also do hot fixes directly on staging for urgent one-commit bugs, and do a normal merge from staging to development)
The problem is step 2. Every time I try to do a squash commit, the commit message includes all the commits going back at least half a year (from when I branched development off master), despite my having already merged them in previous squash commits. I manually prune off all but the relevant ones but at least twice I've forgotten to do this and ended up with an absurdly unwieldy commit message.
What I've seen from the documentation seems to imply that git merge --squash is not supposed to do this and is supposed to intelligently guess which commits I'm squashing. I haven't been able to find an explanation of how it does this so I could figure out what's gone wrong/how to fix it.
How do I fix this? If it can't be fixed directly, is there an alternate workflow I could use that would give me one branch with a full history and one branch with consolidated commits that have references back to where they came from?
Adding further detail:
we'll call common parent 0
feature branch one: 0-A - B - (merge to development, delete branch)
feature branch two: (development from point D) - E- F (merge to development, delete branch)
development: 0-A - B ------------------------------D- E - F-------------
|(source, NOT parent) /(merge from staging) \
staging: 0 --- 1st squash merge(C) - D(version tag) - 2nd squash merge(G) - H (version tag)
That second squash merge has commits A, B, C, D, E, F instead of just E, F recorded in it