I have a test branch with commits a1, a2, a3, a4. I would like to take the changes to the master branch but only in one commit instead of four. So I did:
git checkout master
git merge -Xtheirs test
git rebase -i a1
squash a4 squash a3 squash a2 pick a1
So on master branch I got a commit b1 that included changes from a1, a2, a3, a4.
This worked fine, when done for the first time. Then I continued with my testing branch, adding commits a5, a6, a7, a8. I checked out to master and merged again - I had to resolve the conflicts which is weird because a5 is a continuation of a4 and therefore of b1 as well. Note that git diff
on a4 and b1 did not output any differences.
Then I tried to rebase from a5 and there were even more conflicts.
So it looks that git rebase
is not what I need. After joining the commits, git considers a4 and b1 as different commit objects with different history and what is worse even different position in the graph.
I would like something like:
b0 --- b0 | | a1 | | | a2 | | | a3 | | | a4 ---- b1 | | a5 | | | a6 | | | a7 | | | a8 ---- b2 | | a9 | | | ... --- b3
Is that even possible?
Note, I could create a branch for every group of commits, i.e. one for a1, a2, a3, a4 then do the merge and rebase with master and create another branch from b1 for commits a5, a6, a7, a8 and then do the merge and rebase with master to get b2 and so on. But this is not what I want - it is not desirable to have one branch per day. I want to have only two branches - a test branch with all the commits and a master branch with a rougher granularity. So that when I push master, they would not see every little change I make.