git使用小记---比较

2016-11-23  本文已影响99人  坚果牛奶

变化比较

git diff [--options] [--] [<path>…​]  //eg.  git diff master -- Folder/  develop -- Folder/
git diff [filename]                  //eg.  git diff MyFlder/

比较未commit文件的与上次commit文件的区别(index与HEAD)

git diff --cached [filename]

比较未add文件与上次commit文件的区别(workingtree与HEAD)

git diff HEAD [filename]
workingtree->index->HEAD
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

另附一个将不同命令执行后workingtree, index 和 HEAD之间变化的关系图。workflow

上一篇下一篇

猜你喜欢

热点阅读