製造衝突
當出現衝突時,您需要解決衝突以完成您的工作。在這個步驟中,我們將使用我們現有的兩個儲存庫故意製造衝突,「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
接着,開啟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
現在把tutorial2中的修改推送到遠端儲存庫。
在我們目前的遠端儲存庫中,sample.txt檔案包含第三行pull: Obtain the content of the remote repository,並且已經提交到歷史日誌中。
接下來,我們將把提交從我們的tutorial儲存庫推送到遠端儲存庫。
如您所見,Git 引發了衝突並拒絕了您的推送。