Since I started to work on the same project from both my desktop and laptop, I've been facing a super annoying problem regarding the master branch history:
So I create a feature branch on the desktop, do work, and commit to remote. Later that day, let's say when I'm at the train, I pull the branch on my laptop and commit more stuff, and when I finish I want to squash all the commits and merge the branch to master. The problem is that squashing everything is impossible because some originated from A and some from B...
Of course I can simply merge the branch to master, but then it would be filled with "Continuing X branch" commits - and that's why I want to squash them all.
CodePudding user response:
There is no difference in squashing if the both commits are from the office or one of them is from a different computer. You can follow your normal squashing procedure as if all commits were done from your desk.
Please note that you don't need to squash the commits in the feature branch. You could squash when merging:
git checkout main;
git merge --squash feature_branch
This would create a single commit in main
and keep all the intermediate commit in feature_branch
.
CodePudding user response:
Squashing is possible, from any of your two clones (for example: from your laptop). You will just have to remember to run git fetch
and start working on the correct commit when you go back to your other station (e.g: when you work from your desktop, run git fetch
and switch to the correct commit/branch before coding some more).