V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
git
Pro Git
Atlassian Git Tutorial
Pro Git 简体中文翻译
GitX
leafForFall
V2EX  ›  git

git add -N 和 git add --refresh

  •  
  •   leafForFall · Jun 24, 2017 · 4223 views
    This topic created in 3233 days ago, the information mentioned may be changed or developed.

    最近查看 git-add 的手册,遇到下面的两个选项,有点搞不明白

     -N, --intent-to-add
               Record only the fact that the path will be added later. An entry for the path is placed in
               the index with no content. This is useful for, among other things, showing the unstaged
               content of such files with git diff and committing them with git commit -a.
    
    --refresh
               Don't add the file(s), but only refresh their stat() information in the index.
    

    请问这两个选项的使用场景在哪里呢

    2 replies    2017-06-24 11:18:41 +08:00
    itommy
        1
    itommy  
       Jun 24, 2017
    -N 的场景是:

    - 新加了一个文件,这个文件目前没被 git 追踪的
    - 一般在 git add 之前你希望 diff 看看改了什么内容
    - 这个新文件在 diff 里面是不会出现的
    - 如果想在 diff 里面看到的话,就先把这个文件 add -N <filename>
    - 然后 diff

    --refresh 还没用过
    cyio
        2
    cyio  
       Jun 24, 2017
    平进常用 -p,刚知道新增文件是 -N

    交互式提交,可以有选择的提交部分内容
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2112 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 50ms · UTC 00:33 · PVG 08:33 · LAX 17:33 · JFK 20:33
    ♥ Do have faith in what you're doing.