製造衝突
當出現衝突時,您需要解決衝突以完成您的工作。在這個步驟中,我們將使用我們現有的兩個儲存庫故意製造衝突,「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 引發了衝突並拒絕了您的推送。