8

If multiple people work on a feature branch together, what will happen when you squash and merge it into master? Will git blame keep track of who worked on which part of the feature? Or will the person who clicks squash and merge be pointed to for all git blame? How can you show who is responsible for which part of the feature even though it is in the same PR?

Josh Wang
  • 521
  • 7
  • 17
  • `git blame` will just show the squashed commit. That commit message will contain all of the commit messages from the commits that were squashed. If you really want to preserve all of that history AND use squash and merge, only the original author should commit directly on the PR branch, others should open new PRs against that branch. That way you'll be able to go back to the PR and see the other PRs that were merged into it. It's messy, but possible. – bcr Oct 25 '17 at 18:00

1 Answers1

7

A squash-merge isn't actually a merge, it's just a single ordinary non-merge commit containing changes produced by the merging process (the verb form, to merge). Since the commits are the history, and this squashing process discards the original commits in favor of the new single commit, you are correct: everything winds up assigned to whoever did the squash.

How can you show who is responsible for which part of the feature even though it is in the same PR?

Use a real merge. That adds a merge commit with two parent commits: one is the main line, and the other consists of the individual commits being merged. You can then pick apart the individual commits by following the second parent instead of the first.

torek
  • 448,244
  • 59
  • 642
  • 775