Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happens to git history if multiple people work on a feature branch but it is squash and merged into master?

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?

like image 700
Josh Wang Avatar asked Oct 25 '17 17:10

Josh Wang


1 Answers

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.

like image 86
torek Avatar answered Nov 15 '22 07:11

torek