美文网首页
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使用小记---比较

    变化比较 git diff比较当前未add文件与上一次add文件的区别(workingtree与index) 比较...

  • Git 设置.gitignore 不生效的解决办法

    git学习使用小记 @(Alu)打开git命令行:输入: 清除git的本地版本库缓存再输入: 将你的 .gitig...

  • Git 使用小记

    常用的checkout 或者clonecheckoutcd 你的目录git initgit remote add ...

  • git使用小记

    git diff 命令 1、每修改一次文件,要想比较暂存区和上次提交的变化,都要执行 add命令。2、git st...

  • Git 使用小记

    每个项目都有一个 Git 目录(译注:如果 git clone 出来的话,就是其中 .git 的目录;如果 git...

  • git使用小记

    最近刚入职了一家新公司,代码管理也从熟悉的SVN到不太熟练的git。 以下记录了这段时间使用的比较多的命令。 Gi...

  • Git使用小记

    1、常用命令 初始化 添加一个文件到 暂存区。git add . 添加当前目里下所有文件到暂存区 把暂存区域的文件...

  • Git 使用小记

    Ignore idea foldersgit rm -r --cached .idea Merge a branc...

  • git 代码版本管理工具add、commit、pull、push

    接触git版本管理工具有一段时间了,工作中使用到git,特此小记git代码版本管理工具add、commit、pul...

  • git的基本使用及原理

    git branch testing最近在学习git的使用,看到比较不错的是git手册,以及博客。感觉git手册还...

网友评论

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

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