解決衝突
若要繼續推送我們剛做的修改到遠端儲存庫,我們就必須手動解決衝突。為此,讓我們執行拉取,以從遠端儲存庫獲取最新的變更集。
單擊工具列選單上的「Pull」。

單擊「OK」。

將彈出一個對話方塊警告我們合併衝突。關閉它,然後單擊「Cancel」以取消拉取。
Git 無法完成拉取,因為它無法自動合併有衝突的檔案。遠端分支中的最新更改已下載到您的電腦,但您的工作目錄尚未更新。若要完成拉取,您必須先解決衝突。
選取本地分支中的最新提交,然後單擊「Merge」。然後「OK」。

Sourcetree 將通知您存在合併衝突。單擊「OK」。

現在當您開啟tutorial
資料夾中的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
一旦我們解決了衝突,並且檔案的內容發生變化後,我們將需要啟動提交。
選取「Uncommitted changes」,並選取「Commit」。
我們現在更新了來自遠端儲存庫的最新更改。

這表示這兩個歷史紀錄已成功與新的合併提交合併了。 我們現在可以安全地將此更改推送到遠端儲存庫,而不會發生任何合併衝突。
如果您接下來不想學習在 Command Line 上使用 Git,請直接前往分支的章節。