Reputation: 768
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"?
Upvotes: 1
Views: 284
Reputation: 1323433
git rebase -i HEAD~3
would replay commits (squashed or not) in the bar
branch, leaving the ones referenced by the branch foo
untouched.
It is bad if your branch bar
was already pushed (see "git rebase develop branch"), because you would need to force push it and make other developers on bar
in trouble.
But it is also bad in that it will duplicate commit contents (between those of foo
branch, and the one(s) squashed on bar
, making any future merge from foo
to bar
to 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
)
Upvotes: 1