Ski*_*ick 413
使用:
*.dll #Exclude all dlls
!foo.dll #Except for foo.dll
Run Code Online (Sandbox Code Playgroud)
来自gitignore:
一个可选的前缀!否定了这种模式; 之前模式排除的任何匹配文件将再次包含在内.如果否定模式匹配,则将覆盖较低优先级模式源.
Mat*_*lis 231
如果你写的话,Git会忽略文件夹:
/js
Run Code Online (Sandbox Code Playgroud)
但如果你不能添加例外:
!/js/jquery
或!/js/jquery/
或!/js/jquery/*
你必须写:
/js/*
Run Code Online (Sandbox Code Playgroud)
只有这样你才可以像这样的子文件夹
!/js/jquery
Run Code Online (Sandbox Code Playgroud)
Nil*_*ann 53
你可以简单git add -f path/to/foo.dll
.
.gitignore
忽略通常跟踪的文件和类似的东西 git add .
小智 17
要排除目录中的所有内容,但要排除某些子目录,请执行以下操作:
wp-content/*
!wp-content/plugins/
!wp-content/themes/
Run Code Online (Sandbox Code Playgroud)
资料来源:https://gist.github.com/444295
Rob*_*anu 14
只需!
在排除规则之前添加.
根据gitignore手册页:
模式具有以下格式:
...
- 一个可选的前缀!否定了这种模式; 之前模式排除的任何匹配文件将再次包含在内.如果否定模式匹配,则将覆盖较低优先级模式源.
对于嵌套文件夹,我根据马蒂斯的答案提出了一个解决方案。
假设我想忽略build/
目录中的所有内容(位于/app
)。所以我这样做:
build/*
Run Code Online (Sandbox Code Playgroud)
但是,如果我想排除build/outputs/bundle/release
子文件夹,我需要玩一些捉迷藏!
/app/build/*
!/app/build/outputs
/app/build/outputs/*
!/app/build/outputs/bundle
/app/build/outputs/bundle/*
!/app/build/outputs/bundle/release
Run Code Online (Sandbox Code Playgroud)
/
以.gitignore
如果您正在使用 Visual Studio 并且您的 .dll 恰好位于一个bin
文件夹中,那么您需要先为特定的 bin 文件夹本身添加一个例外,然后才能为 .dll 文件添加例外。例如
!SourceCode/Solution/Project/bin
!SourceCode/Solution/Project/bin/My.dll
Run Code Online (Sandbox Code Playgroud)
这是因为默认的 Visual Studio.gitignore
文件包含一个忽略模式[Bbin]/
这种模式正在清除所有 bin 文件夹(以及它们的内容),这使得任何包含内容的尝试都是多余的(因为文件夹本身已经被忽略)。
我能够通过运行找到为什么我的文件没有被排除在外
git check-ignore -v -- SourceCode/Solution/Project/bin/My.dll
Run Code Online (Sandbox Code Playgroud)
从 Git Bash 窗口。这返回了[Bbin]/
模式。
归档时间: |
|
查看次数: |
83577 次 |
最近记录: |