fast-forward merges
Only criteria for whether something would be a fast-forward merge is if the branch you are merging into is an ancestor of the branch that you're merging from.
合并冲突
如果收到类似以下所示的消息:
Auto-merging game.js CONFLICT (content): Merge conflict in game.js Automatic merge failed; fix conflicts and then commit the result.
这表示在你开始合并时,文件的状态不同于 Caroline 的文件状态。要修复此问题,请完成以下步骤:
- 运行
git merge --abort,将文件恢复到你开始合并之前的状态 - 仔细检查文件的状态。如果在检出 master 分支时运行
git log,则应看到 Caroline 的“Add color”提交是第二新的提交,而最新的提交应为你修复 bullet 错误的提交。如果使用git diff将你的提交与 Caroline 的提交进行对比,你的提交应在第 424 行引入this.delayBeforeBullet = 10;这行代码。应仅使用空格(无制表符)使该行的缩进程度与其下面一行相同,而且该行之后应无空格。 - 在文件处于正确的状态后,利用你所做的更改新建一个提交。
- 重新尝试合并。
合并冲突(Windows 与 Unix 系统之间的换行符)
背景:按下键盘上的“Enter”键时,实际上是告诉计算机在文本文件中插入一个不可见的字符,以便指示计算机应新起一行。Unix 系统会添加一个名为“换行”符的字符(或者 LF 或 \),而 Windows 系统会添加两个字符,即“回车”和“换行”(或者 CRLF 或 \r\n)。
Caroline 的文件包含 LF,因为她的文件是在使用 LF 的 Mac OSX 上编辑的。如果某 Windows 用户要编辑 Caroline 的文件,Windows 文本编辑器可能会将所有 LF 均转换为 CRLF,以便该用户能够编辑文件。在该 Windows 用户将她的文件与 Caroline 的文件合并时,不同的 LF 和 CRLF 字符将会造成合并冲突。
要修复此问题,Windows 用户应将 autocrlf 全局属性设置为 true:
git config --global core.autocrlf true。有关更多信息,请访问以下网址:https://help.github.com/articles/dealing-with-line-endings/#platform-all将提交与所在分支进行对比
Caroline 提到的将提交与所在分支进行对比的命令是
git show commit_id當出現conflict時
<<<<
|||||| merge common ancestors
//The middle section is the original version that both branches modified
====
//The bottom section, marked master is the code that's in master right now.>>>>>master
參考資料來源
https://classroom.udacity.com/courses/ud775/lessons/2969618657/concepts/29892386280923


No comments:
Post a Comment