git diff 結果分析

來源:互聯網
上載者:User

標籤:工作   小結   commit   diff   命令   開頭   pre   efs   .cpp   

git diff 的5個使用情境:

1.staging area和working area的檔案 (無其他參數時)

git diff  

2.master分支和working area的檔案 (用master參數)

git diff master 

3.HEAD指向的內容和working area的檔案

git diff HEAD 

4.用遠程master分支比較當前工作區

git diff refs/remotes/origin/master 

5.經常還要用到master分支的某個檔案的曆史版本和working area的該檔案的比較

git diff 0c5ee16a6a4c849d0ae0448caa8ff174399c7c3c ./socket_helper.cpp 

上面的命令中, diff後面的參數指的是commit id, ./socket_helper.cpp是要比較的檔案路徑。

diff的命令輸出格式注意:

---代表源檔案  +++代表目標檔案  

通常working area的檔案都是被當作目標檔案來看待。

-開頭的行,是只出現在源檔案中的行+開頭的行,是只出現在目標檔案中的行空格開頭的行,是源檔案和目標檔案中都出現的行

-差異按照差異小結進行組織,每個差異小結的第一行都是定位語句,由@@開頭,@@結尾。

git diff 結果分析

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.