V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
git
Pro Git
Atlassian Git Tutorial
Pro Git 简体中文翻译
GitX
leafForFall
V2EX  ›  git

git add -N 和 git add --refresh

  •  
  •   leafForFall · 2017-06-24 10:15:58 +08:00 · 3307 次点击
    这是一个创建于 2469 天前的主题,其中的信息可能已经有所发展或是发生改变。

    最近查看 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 条回复    2017-06-24 11:18:41 +08:00
    itommy
        1
    itommy  
       2017-06-24 10:24:06 +08:00
    -N 的场景是:

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

    --refresh 还没用过
    cyio
        2
    cyio  
       2017-06-24 11:18:41 +08:00
    平进常用 -p,刚知道新增文件是 -N

    交互式提交,可以有选择的提交部分内容
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3249 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 14:00 · PVG 22:00 · LAX 07:00 · JFK 10:00
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.