1. 程式人生 > >Git:merge後如何檢查是否還存在衝突沒有處理

Git:merge後如何檢查是否還存在衝突沒有處理

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

Git:merge後如何檢查是否還存在衝突沒有處理。

正文

在工作中,遇到一個問題,在git merge後,發生衝突,而當衝突較多的時候,逐個檢查衝突,有的時候會遺漏一些檔案,導致帶有衝突標記的檔案上傳到了Git伺服器上。

使用以下命令可以快速檢查是否還存在有帶有衝突標記的檔案。
git diff --check

說明:

–check
Warn if changes introduce conflict markers or whitespace errors. What are considered whitespace errors is controlled by core.whitespace configuration. By default, trailing whitespaces (including lines that consist solely of whitespaces) and a space character that is immediately followed by a tab character inside the initial indent of the line are considered whitespace errors. Exits with non-zero status if problems are found. Not compatible with --exit-code.

上文摘錄自手冊官網,這個命令會檢查conflict markers(衝突標記)和whitespace errors(空格錯誤)。

總結

Git是一個相對比較複雜的工具,我發現,複雜往往源自於過於靈活,它的功能非常強大,掌握好了,就可以事半功倍,但是,把它掌握好,是需要花費一些時間成本的。感覺學習Git,可能需要既需要正面地一篇篇去閱讀手冊,也需要這樣涓涓細流地不斷總結各種場景下的用法,也許,這本身就是學習的一種方法。

參考

https://git-scm.com/docs/git-diff
https://ardalis.com/detect-git-conflict-markers