制造冲突
当出现冲突时,您需要解决冲突,以完成您的工作。在这个步骤中,我们将使用我们现有的两个存储库故意制造冲突,”tutorial“和”tutorial2”。
首先,打开tutorial
目录中的sample.txt
文件。将下面的粗体文本添加到文件中并提交。
Anyone can learn Git with this tutorial and Backlog
add: Register a change in an index
commit: Save the status of an index
![Record the status of commit index](/static/4e9a8f49ec25d1845324f70ea1eab76b/5a190/01.png)
接着,打开tutorial2
目录中的sample.txt
文件。将下面的粗体文本添加到文件中并提交。
Anyone can learn Git with this tutorial and Backlog
add: Register a change in an index
pull: Obtain the content of the remote repository
![pull Acquire the contents of a remote repository.](/static/872e42c66e37b3235eba483a2d018be7/5a190/02.png)
现在把tutorial2
中的修改推送到远程存储库。
![Push to the remote repository](/static/16e668f363254db234adcd68f556befa/5a190/03.png)
在我们当前的远程存储库中,sample.txt
文件包含第三行pull: Obtain the content of the remote repository
,并且已经提交到历史日志中。
接下来,我们将把提交从我们的“tutorial”存储库推送到远程存储库。
![Git raises a conflict and rejects your push](/static/aad1db1136d67488d3905f317fd9b91f/5a190/04.png)
如您所见,Git 引发了冲突并拒绝了您的推送。