我知道.gitignore文件隐藏了Git版本控制中指定的文件.我有一个项目(LaTeX),它在运行时会生成许多额外的文件(.auth,.dvi,.pdf,日志等),但我不希望这些文件被跟踪.
我知道我可以(也许应该)这样做所有这些文件放在项目中的一个单独的子文件夹中,因为我可以忽略该文件夹.
但是,有没有可行的方法将输出文件保存在项目树的根目录中,并使用.gitignore忽略除了我用Git跟踪的文件之外的所有内容?就像是
# Ignore everything
*
# But not these files...
script.pl
template.latex
# etc...
Run Code Online (Sandbox Code Playgroud) 我的问题是我的git仓库里有一堆WordPress网站,其中我想有选择地只提交我themes文件夹的内容,而忽略了WordPress中的其余冗余文件.
我之前使用.gitignore文件来忽略文件类型,但它可以反过来使用 - 即忽略一切但是某个文件夹路径?
root(git repo)
- /wordpress
- - /(WordPress Site 1)/ wp-content/themes
- - /(WordPress Site 2)/ wp-content/themes
- - /(WordPress Site 3)/ wp-content/themes
谢谢-
更新:
根据答案我做了以下,但它不起作用.有任何想法吗?
# Ignore everything:
*
# Except for wordpress themes:
!*/wp-content/themes/*
Run Code Online (Sandbox Code Playgroud)
我也尝试了以下变化:
!*/wp-content/themes*
!*wp-content/themes/*
!wp-content/themes/*
!/wordpress/*/wp-content/themes*
!wordpress/*/wp-content/themes*
Run Code Online (Sandbox Code Playgroud)
这些都没有读取我的themes文件夹.
我知道有很多这样的问题,但没有人解决我的问题.我想要一些非常简单的东西 - 忽略特定文件夹下的所有文件和文件夹,除了一个文 这是我尝试的:
#Ignore
public/typings/*
#Allow
!public/typings/browser/ambient/jquery/jquery.d.ts
Run Code Online (Sandbox Code Playgroud)
...但文件仍被忽略.
有什么建议?
回购结构:
.gitignore
file1
file2
dir/
file3
<stuff>
Run Code Online (Sandbox Code Playgroud)
我想忽略dir文件3之外的所有内容。这是.gitignore文件中包含的内容:
dir/*
!dir/file3
Run Code Online (Sandbox Code Playgroud)
但这似乎不起作用。git仍然尝试索引中的所有内容dir。我该如何解决?
更新 -删除旧的.gitignore文件并制作一个新文件后修复。新的不是使用制作的> .gitignore。