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 · 3348 次点击
    这是一个创建于 2505 天前的主题,其中的信息可能已经有所发展或是发生改变。

    腾讯云最新优惠活动来了:云产品限时1折,云服务器低至88元/年 ,点击这里立即抢购:9i0i.cn/qcloud,更有2860元代金券免费领取,付款直接抵现金用,点击这里立即领取:9i0i.cn/qcloudquan

    (福利推荐:你还在原价购买阿里云服务器?现在阿里云0.8折限时抢购活动来啦!4核8G企业云服务器仅2998元/3年,立即抢购>>>:9i0i.cn/aliyun

    最近查看 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   ·   我们的愿景   ·   实用小工具   ·   780 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 20:50 · PVG 04:50 · LAX 13:50 · JFK 16:50
    Developed with CodeLauncher
    ? Do have faith in what you're doing.


    http://www.vxiaotou.com