Tru*_*ill 11 windows git gitignore nuget
我正在尝试实现NuGet包还原问题的解决方法.
这涉及忽略层次结构中任何级别的所有包文件夹的内容.但是,不应忽略.targets文件(通常位于包文件夹的子文件夹中).
例如:
.gitignore
YourProject/
YourProject.csproj
packages/
repositories.config
Microsoft.Bcl.Build.1.0.7/
lib/
foo.dll
tools/
Microsoft.Bcl.Build.targets
应该只包含文件:
Windows,git版本1.8.1.msysgit.1.
我已经在StackOverflow上阅读了几个答案,检查了手册页,并尝试了许多变种而没有成功.
这不起作用:
packages/*
!*.targets
Run Code Online (Sandbox Code Playgroud)
这不是:
packages/*
!packages/**/*.targets
Run Code Online (Sandbox Code Playgroud)
这不是:
**/packages/*
!**/packages/**/*.targets
Run Code Online (Sandbox Code Playgroud)
更新:
bin/必须继续工作.没有"好"的方法(参见手册页作为证据),但是它周围有一个黑客.
忽略packages/bat的主要问题是git甚至没有检查它的子目录,因为目录被忽略了.
解决方案 - 你必须有2个gitignore文件.一个常规的,一个在packages目录中,如下所示:
# ignore all files
*
# do not ignore directories
!*/
# do not ignore targets
!*.targets
# do not ignore gitignore
!*.gitignore
Run Code Online (Sandbox Code Playgroud)
新例子:
$ mkdir foo
$ cd foo/
$ mkdir foo
$ mkdir foo/bar
$ mkdir foo/bar/baz
$ touch foo/.foo
$ touch foo/bar/.foo
$ touch foo/bar/baz/.foo
$ touch regular.txt
$ touch foo/ignored.txt
$ touch foo/bar/baz/ignored-2.txt
$ cat foo/.gitignore
*
!*/
!*.foo
!regular.txt
!.gitignore
$ git add . && git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: foo/.foo
# new file: foo/bar/.foo
# new file: foo/bar/baz/.foo
# new file: regular.txt
#
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3877 次 |
| 最近记录: |