1. 程式人生 > >Git:merge的時候全部採用某一個端的檔案

Git:merge的時候全部採用某一個端的檔案

原帖收藏於IT老兵驛站,傳遞一個IT老兵在凋零前的光和氧。

Git:merge的時候全部採用某一個端的檔案。

正文

在Git使用過程中,有的時候進行merge,可能需要會全部採用某一端的檔案,換句話說,就是完全採用本地的,或者完全採用遠端的,怎麼實現這個功能呢?

使用merge命令:

# keep remote files
git merge --strategy-option theirs
# keep local files
git merge --strategy-option ours

官網是這樣寫的

--strategy-option=<option>


Pass merge strategy specific option through to the merge strategy.

這裡的策略選項可以參考另外一篇文章《Git:真實merge》。

git-pull也有同樣的功能:

git pull -X theirs

原理是一樣的。

參考

https://stackoverflow.com/questions/6650215/how-to-keep-the-local-file-or-the-remote-file-during-merge-using-git-and-the-com
https://stackoverflow.com/questions/10697463/resolve-git-merge-conflicts-in-favor-of-their-changes-during-a-pull