i am wondering what happens if you squash between branches and push/pull from remote in between.
DEVELOPER 1
1. $ git checkout foo
2. $ git commit -m 'changed file' file.txt
$ git commit -m 'changed another file' file2.txt
3. $ git push
DEVELOPER 2
4. $ git checkout foo
5. $ git pull // gets commits from 2. above
6. $ git checkout bar
7. $ git merge foo
8. $ git rebase -i HEAD~3
in 1 – 3 — i make some local changes to some files, commit them separately, then push.
in 4 – 8 — someone else pulls my commits, checks out another branch, merges the first one, then tries to squash the commit in the merge.
would this mess up history, is it “bad”?
git rebase -i HEAD~3would replay commits (squashed or not) in thebarbranch, leaving the ones referenced by the branchfoountouched.It is bad if your branch
barwas already pushed (see “git rebase develop branch“), because you would need to force push it and make other developers onbarin trouble.But it is also bad in that it will duplicate commit contents (between those of
foobranch, and the one(s) squashed onbar, making any future merge fromfootobarto apply again commits 2 and 3.That is where the option
-p(--preserve-merges) of a rebase can come in handy, in order to preserve the parents of a merge. But that might not be compatible with what you want to do (squash).In general, try to not modify a public history that you just pulled (like commit 2 and 3 on branch
foo)