如何在不同步 Build Result 的情况下同步与 Build result 同文件夹的文件? - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
git
Pro Git
Atlassian Git Tutorial
Pro Git 简体中文翻译
GitX
x1155665
V2EX    git

如何在不同步 Build Result 的情况下同步与 Build result 同文件夹的文件?

  •  
  •   x1155665 2016-08-01 07:40:50 +08:00 2943 次点击
    这是一个创建于 3369 天前的主题,其中的信息可能已经有所发展或是发生改变。
    环境:用 visual studio 写 c# 程序,用 git 同步。

    程序运行需要使用试用一些附件的文件(比如图片文件),我把这些附加文件放在 build result 的文件夹里,这样方便程序直接调用。但是 build result 默认是不被同步的,整个文件夹被 git 排除了。有没有什么办法可以同步这些附加文件而不同步临时的 Build result 文件?(不要一个一个排除临时文件后缀的办法。。)

    或者是可以把这些所需的文件直接添加到 c# 项目里,然后 Build 的时候 VS 直接自动把文件复制到 Build result 文件夹里?
    5 条回复    2016-08-01 20:01:56 +08:00
    livelazily
        1
    livelazily  
       2016-08-01 08:39:05 +08:00
    至少你得把那些附件文件放到 Build result 的某个子目录下,然后 .gitignore 里使用
    !buildresult/resourcexxx
    来排除忽略
    如果是直接在 build result 下的话, 你就得一个一个加文件名排除
    wysnylc
        2
    wysnylc  
       2016-08-01 08:45:00 +08:00
    shell 脚本
    x1155665
        3
    x1155665  
    OP
       2016-08-01 15:45:17 +08:00
    @livelazily 不能这么做。。因为母文件夹 build result 已经被排除了。

    “ An optional prefix "!" which negates the pattern; any matching file excluded by a previous pattern will become included again. It is not possible to re-include a file if a parent directory of that file is excluded. Git doesn ’ t list excluded directories for performance reasons, so any patterns on contained files have no effect, no matter where they are defined. Put a backslash ("\") in front of the first "!" for patterns that begin with a literal "!", for example, "\!important!.txt" ”
    livelazily
        4
    livelazily  
       2016-08-01 19:04:28 +08:00   1
    @x1155665 这样试试:
    工程根目录.gitignore 文件不忽略 buildresult ,
    buildresult 文件夹内再新建一个 .gitignore 文件, 内容:

    #ignore everything in this directory
    *
    # Except this dir
    !resourcexxx
    x1155665
        5
    x1155665  
    OP
       2016-08-01 20:01:56+08:00
    @livelazily 靠谱!
    一些细节需要改一下:
    build result 文件夹里的 .gitignore 文件内容:

    #ignore everything in this directory
    *
    # Except this dir
    !resourcexxx/*

    解释:/ 对于表示文件夹是必须的,/ 后面加 * 是为了让 resourcexxx 的子文件里的文件也可以被包括。
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     4550 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 31ms UTC 10:01 PVG 18:01 LAX 03:01 JFK 06:01
    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