git 如何指定某个文件暂时不提交? - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
请不要在回答技术问题时复制粘贴 AI 生成的内容
eightqueen

git 如何指定某个文件暂时不提交?

  •  
  •   eightqueen 2016 年 1 月 10 日 10818 次点击
    这是一个创建于 3757 天前的主题,其中的信息可能已经有所发展或是发生改变。
    场景是这样的,我修改了 20 个 java 文件, 1 个 xml 文件,我希望提交 20 个 java 文件的修改, xml 文件还需要进一步完善。可是 20 个 java 文件一个一个去 add ,感觉好 low ,又不能直接执行“ git add .”。
    11 条回复    2016-01-10 18:56:16 +08:00
    sophymax
        1
    sophymax  
       2016 年 1 月 10 日 via Android
    git stash
    guchengf
        2
    guchengf  
       2016 年 1 月 10 日
    你可以 add .
    然后 reset xml

    或者

    https://github.com/ndbroadbent/scm_breeze
    Vvfan
        3
    Vvfan  
       2016 年 1 月 10 日
    git update-index

    --[no-]assume-unchanged
    When this flag is specified, the object names recorded for the paths
    are not updated. Instead, this option sets/unsets the "assume
    unchanged" bit for the paths. When the "assume unchanged" bit is on,
    the user promises not to change the file and allows Git to assume that
    the working tree file matches what is recorded in the index. If you
    want to change the working tree file, you need to unset the bit to
    tell Git. This is sometimes helpful when working with a big project on
    a filesystem that has very slow lstat(2) system call (e.g. cifs).

    Git will fail (gracefully) in case it needs to modify this file in the
    index e.g. when merging in a commit; thus, in case the
    assumed-untracked file is changed upstream, you will need to handle
    the situation manually.
    zapper
        4
    zapper  
       2016 年 1 月 10 日 via iPhone
    暂存 然后提交了再取出?
    cloudzhou
        5
    cloudzhou  
       2016 年 1 月 10 日
    git status|grep modified|grep java$|awk '{print $NF}'|xargs git add
    linhua
        6
    linhua  
       2016 年 1 月 10 日
    finian
        7
    finian  
       2016 年 1 月 10 日
    用 GUI 吧,比如 SourceTree ,直观省事
    crayygy
        8
    crayygy  
       2016 年 1 月 10 日
    git add *.java ?
    az
        9
    az  
       2016 年 1 月 10 日
    可以临时 checkout 到一个新的分支 commit ,完了再回来,在 reset 。
    chemzqm
        10
    chemzqm  
       2016 年 1 月 10 日
    git add **/*.java
    或者
    git add .
    git reset --- path-to-xml
    不加 hard git 不会动工作目录
    timwu
        11
    timwu  
       2016 年 1 月 10 日
    git stash 正解,推荐 sourcetree
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     2842 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 49ms UTC 13:00 PVG 21:00 LAX 06:00 JFK 09:00
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86