美文网首页
git使用小记---比较

git使用小记---比较

作者: 坚果牛奶 | 来源:发表于2016-11-23 21:27 被阅读99次

    变化比较

    • git diff
      比较当前未add文件与上一次add文件的区别(workingtree与index)
    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
    • git add -p
      会显示当前未add文件与working tree文件的区别,并可选择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
    

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

    相关文章

      网友评论

          本文标题:git使用小记---比较

          本文链接:https://www.haomeiwen.com/subject/jnampttx.html