Reputation: 7099
When I'm working on a large feature that takes me few days to implement I do many small commits to my local git repository and also pull others' changes from the remote master repository. After the feature is complete, my local git repo looks somehow like:
Now, I would like to push all local commits to the remote repo as a single commit that adds the feature X. Squashing commits with 'git rebase' won't work in this case, because remote commits not done by me (2 and 5) would also need to be squashed, which is not an option.
The only way that I managed to figure out was to have a clean branch with only remote commits, issue 'git diff' against my local development branch and apply a resulting patch onto the clean branch. Then commit patched changes and push. Is there a better way?
Upvotes: 1
Views: 1686
Reputation: 7099
I found the answer: git rebase -i actually allows to reorder commits, and when all local commits are reordered to be in sequence (not interleaved with remote commits), they can be all squashed into one.
Upvotes: 3