解决冲突
若要继续推送我们刚做的修改到远程存储库,我们就必须手动解决冲突。为此,让我们执行拉取以从远程存储库获取最新的更改集。
右键单击“tutorial”目录,然后选择“Pull”。

单击“OK”。

如果您看到一个教您合并的信息框,请阅读它并单击“OK”。

当您看到自动合并失败的警告消息时,单击“Close”。

然后系统会询问您是否要查看此修订版中的更改。单击“Yes”。

TortoiseGit 告诉我们自动合并失败,因为“sample.txt”有合并冲突。单击“OK”。

当您打开sample.txt
时,您会看到 Git 添加的标记表明该文件章节存在冲突,如下所示。
Anyone can learn Git with this tutorial and Backlog
add: Register a change in an index
<<<<<<< HEAD
commit: Save the status of an index
=======
pull: Obtain the content of the remote repository
>>>>>>> 17c860612953c0f9d88f313c8dfbf7d858e02e91
我们将通过接受两个更改,并移除标记来解决冲突。
Anyone can learn Git with this tutorial and Backlog
add: Register a change in an index
commit: Save the status of an index
pull: Obtain the content of the remote repository
一旦我们解决了冲突,并且文件的内容发生变化后,我们将需要启动提交。
右键单击并选择Git Commit -> 'main'
。
将显示一个关于合并的窗口;单击“OK”。

右键单击示例文件,并选择“Resolved”,因为我们刚才使用我们的文本编辑器手动解决了这个合并冲突。

当显示确认此更改的窗口时,单击“Yes”。

当被警告提交信息仍然提到冲突的文件时,选择“Ignore”或“Abort”。然后从提交信息中移除这些行,或者按照底部的建议,让 TortoiseGit 自动为您移除以“#”开头的行。(自动移除这些行是大多数其他 Git 客户端的默认行为)。
我们现在更新了来自远程存储库的最新更改。

这表明这两个历史记录已成功与新的合并提交合并了。 我们现在可以安全地将此更改推送到远程存储库,而不会发生任何合并冲突。
如果您接下来不想学习在 Mac 或 Command Line 上使用 Git,请直接前往分支的章节。