我知道.gitignore文件隐藏Git版本控制中的指定文件。
我如何告诉.gitignore忽略除我使用Git跟踪的文件之外的所有内容?类似于:
# Ignore everything:
*
# Do not ignore these files:
script.pl
template.latex
我知道.gitignore文件隐藏Git版本控制中的指定文件。
我如何告诉.gitignore忽略除我使用Git跟踪的文件之外的所有内容?类似于:
# Ignore everything:
*
# Do not ignore these files:
script.pl
template.latex
当前回答
我把它搞定了
# Vendor
/vendor/braintree/braintree_php/*
!/vendor/braintree/braintree_php/lib
其他回答
Gist
# Ignore everything
*
# But not these files...
!script.pl
!template.latex
可能包括:
!.gitignore
参考
从…起https://git-scm.com/docs/gitignore:
一个可选前缀“!”,用于否定模式;被先前模式排除的任何匹配文件将再次包含。如果排除了文件的父目录,则无法重新包含该文件。由于性能原因,Git没有列出排除的目录,因此包含的文件上的任何模式都不会产生任何影响,无论它们是在哪里定义的。对于以文字“!”开头的模式,在第一个“!”前面加一个反斜杠(“\”),例如“\!important!.txt”。...排除除特定目录foo/bar以外的所有内容的示例(注意/*-不带斜杠,通配符也会排除foo/bar内的所有内容):$cat.gitignore#排除目录foo/bar以外的所有内容/*!/食品/食品/*!/foo/条
我有博沃的Jquery和Angular。Bower将其安装在
/public_html/bower_components/jquery/dist/bunch-of-jquery-files
/public_html/bower_components/jquery/src/bunch-of-jquery-source-files
/public_html/bower_components/angular/angular-files
最小化的jquery位于dist目录中,angular位于angular目录中。我只需要最小化的文件就可以提交到github。对gitignore进行了一些篡改,这就是我设法变出来的。。。
/public_html/bower_components/jquery/*
!public_html/bower_components/jquery/dist
/public_html/bower_components/jquery/dist/*
!public_html/bower_components/jquery/dist/jquery.min.js
/public_html/bower_components/angular/*
!public_html/bower_components/angular/angular.min.js
希望有人能发现这个有用。
要忽略目录中的某些文件,必须按正确的顺序执行此操作:
例如,忽略文件夹“application”中除index.php和文件夹“config”外的所有内容,注意顺序。
你必须先否定你想要的。
失败
应用程序/*
!应用程序/配置/*
!应用程序/index.php
作品
!应用程序/配置/*
!应用程序/index.php
应用程序/*
最简单的方法是强制添加文件。即使它被隐藏或嵌套在git忽略的子目录树中,它也将在git中进行说明。
例如:
x64文件夹已在中排除。gitignore:
x64/
但您希望包含位于x64/发布/目录中的文件myFile.py。然后你必须:
git add -f x64/Release/myFile.py
您可以对匹配模式的多个文件执行此操作,例如。
git add -f x64/Release/myFile*.py
等等
您可以使用git-config-status.showUntrackedFiles no,所有未跟踪的文件都将对您隐藏。有关详细信息,请参阅man git config。