user7692855
user7692855

Reputation: 1428

GIT Squash: Does it cause issues?

Let's say we have a feature branch called feature-branch. Developers branch of this branch for their tickets and then open a PR to feature-brach.

If the following happens:

  1. Developer A branches off feature-branch and develops on a branch ticket-a
  2. Developer B then goes to feature-branch and squashes two previous commits into one.
  3. Developer A goes to merge ticket-a into feature-branch

Will there be a merge conflict or any issues? Since the ticket-a branch will have two commits where as the feature-branch will only have one as the two commits were squashed.

Upvotes: 3

Views: 2150

Answers (1)

Aurora Wang
Aurora Wang

Reputation: 1940

If you have something like:

Ancestor -- A -- B
                  \-- C

And you do a squash:

Ancestor -- AB
        \-- A -- B -- C

You would be changing your history branch and creating a new commit with a new hash. Therefore, if you attempt to merge those two branches, git will try and find their common ancestor and begin your merge from there. But A doesn't contain all the changes AB does, which can cause conflicts.

To fix this, I suggest you rebase your other branch so it will contain the squashed commit. You can accomplish this with rebase onto from your second branch:

git rebase --onto AB C branch2

Upvotes: 3

Related Questions