如果我解决冲突会不会改变Git责备? [英] If I Resolve a Conflict Does it Change Git Blame?
问题描述
我试图弄清楚合并冲突是否对错误负责,但是我遇到了困难,因为我不清楚冲突解决如何影响 git blame $ c $
假设我在master中有一个文件:
一();
b();
c();
我在master中修改它:
A();
d();
c();
但是同事也是如此,他们对此进行了不同的修改,合并到master:
a();
e();
c();
解决冲突会影响责任吗?换句话说,如果我的同事通过我的版本解决冲突:
d();
c();
和I git blame
d();
line,谁会被指责:我还是我的同事?同样的,让我们说git弄糊涂了并认为第一行和第二行都有冲突:
<<<<
a();
d();
====
a();
e();
>>>>
如果我的同事解决了与他们版本的冲突:
a();
e();
c();
和I git blame
a();
行,我(该行的原作者)会受到责备,还是会让我的同事(最后一次触摸它,即使它们没有改变它)得到责备?
tl; dr
如果你在合并的文件上运行 git blame
,您将看到每行的原始作者,无论谁进行了合并提交。这意味着如果您的同事决定使用该行的您的版本解决冲突,那么您的姓名将显示在其旁边。
重建文件的历史记录
在Git中,每个提交包含两个关键信息: 鉴于这两个事实,Git可以通过从一个给定的提交中退回,在每个步骤中生成当前版本的文件和前一个版本之间的差异。 这正是 A merge commit提供了两个父母的引用: 快照包含每一方合并的所有更改。 如果您在一个 merge commit 上做一个 如果添加了一行新行 - 即不属于合并任何一侧的行 - 作为一个冲突解决方案,该行将属于合并提交本身所引用的快照。在这种情况下, I'm trying to figure out whether a merge conflict was responsible for a bug, but I'm having difficulty because I'm not clear on how conflict resolution affects Let's say I have a file in master: I modify it in master: but so does a co-worker, and they modify it differently, in a separate branch which they then merge in to master: Can resolving that conflict affect the blame? In other words, if my co-worker resolves the conflict by going with my version: and I Similarly, let's say git got confused and thought both the first and second lines were conflicted: If my co-worker resolves the conflict with their version: and I If you run In Git each commit holds two key pieces of information: Given these two facts Git can reconstruct the history of changes occurred in a file by walking backwards from a given commit, generating at each step a diff between the current version of the file and its previous one. This is exactly what A merge commit holds a reference to two parents: The snapshot contains all the changes from each side combined. If you do a If a new line – that is a line that doesn't belong to either side of the merge – was added as part of a conflict resolution, that line would belong to the snapshot referenced by the merge commit itself. In that case 这篇关于如果我解决冲突会不会改变Git责备?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
git blame
的确如此。当你在一个文件上执行 git blame
时,Git会在行的基础上重建文件的历史记录,向你显示作者提交引入(即添加)每行。
合并提交
git blame
,Git将走两行历史记录,每个父提交一行。一旦Git到达其快照添加某个行的提交,它会在该行旁边显示该提交的作者。
解析时添加新行冲突
git blame
会报告该行的合并提交的作者。git blame
.a();
b();
c();
a();
d();
c();
a();
e();
c();
a();
d();
c();
git blame
the d();
line, who will be blamed: me or my co-worker?<<<<
a();
d();
====
a();
e();
>>>>
a();
e();
c();
git blame
the a();
line, will I (the line's original author) get the blame, or will my co-worker (who "touched" it last, even though they didn't change it) get the blame?tl;dr
git blame
on a merged file you are going to see the original author of each line, regardless of who did the merge commit. This means that if your co-worker decided to resolve the conflict using your version of the line, your name will be shown next to it.Reconstructing the history of a file
git blame
does. When you do git blame
on a file, Git will reconstruct the history of the file on a line by line basis, showing you the author of the commit that introduced (i.e. added) each line.Merge commits
git blame
on a merge commit, Git will walk two lines of history, one for each of the parent commits. Once Git reaches the commit whose snapshot added a certain line, it will show that commit's author next to the line.Adding new lines when resolving a conflict
git blame
will report the author of the merge commit for that line.