git使用小記---比較

變化比較

  • git diff
    比較當(dāng)前未add文件與上一次add文件的區(qū)別(workingtree與index)
git diff [--options] [--] [<path>…?]  //eg.  git diff master -- Folder/  develop -- Folder/
git diff [filename]                  //eg.  git diff MyFlder/

比較未commit文件的與上次commit文件的區(qū)別(index與HEAD)

git diff --cached [filename]

比較未add文件與上次commit文件的區(qū)別(workingtree與HEAD)

git diff HEAD [filename]
workingtree->index->HEAD
  • git add -p
    會顯示當(dāng)前未add文件與working tree文件的區(qū)別,并可選擇add的方式
Stage this hunk [y,n,q,a,d,/,s,e,?]? n
y - stage this hunk
n - do not stage this hunk
q - quit; do not stage this hunk or any of the remaining ones
a - stage this hunk and all later hunks in the file
d - do not stage this hunk or any of the later hunks in the file
g - select a hunk to go to
/ - search for a hunk matching the given regex
j - leave this hunk undecided, see next undecided hunk
J - leave this hunk undecided, see next hunk
k - leave this hunk undecided, see previous undecided hunk
K - leave this hunk undecided, see previous hunk
s - split the current hunk into smaller hunks
e - manually edit the current hunk
? - print help

另附一個將不同命令執(zhí)行后workingtree, index 和 HEAD之間變化的關(guān)系圖。workflow

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 因為原文太長超出字?jǐn)?shù),Lesson 3 就放在另一篇文章里 How to Use Git and GitHub 標(biāo)...
    赤樂君閱讀 5,500評論 1 5
  • 1.git的安裝 1.1 在Windows上安裝Git msysgit是Windows版的Git,從https:/...
    落魂灬閱讀 12,843評論 4 54
  • 臨近春節(jié),學(xué)校放寒假了,下午放學(xué),小五還沒進(jìn)家門口就高興地喊著,放假咯,放假咯,或許是他年紀(jì)還小,對學(xué)習(xí)還不是很感...
    時間印記閱讀 274評論 0 0
  • 進(jìn)入培訓(xùn)崗位之后的這幾十天,面對90后小孩兒的種種問題,腦子里現(xiàn)在出現(xiàn)的一句話就是:成年人只講利弊,小孩子才分對錯...
    baibeely閱讀 465評論 0 0
  • 望都峰,是嵩山太室山上一座較高的山峰,其名字在直白不過了。它真切地告訴你,每當(dāng)晴空時,站在峰巔可以望見洛陽。您別不...
    鷹_張朝民閱讀 777評論 0 0

友情鏈接更多精彩內(nèi)容