相关疑难解决方法(0)

Make .gitignore会忽略除少数文件之外的所有内容

我知道.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 gitignore

1531
推荐指数
22
解决办法
42万
查看次数

.gitignore排除文件夹但包含特定的子文件夹

我有文件夹application /我添加到.gitignore.应用程序/文件夹内是文件夹application/language/gr.我该如何包含此文件夹?我试过这个

application/
!application/language/gr/
Run Code Online (Sandbox Code Playgroud)

没有运气......

git gitignore

863
推荐指数
14
解决办法
32万
查看次数

解释哪个gitignore规则忽略了我的文件

有没有办法看到为什么一些文件被git忽略(即.gitignore文件中的哪个规则导致文件被忽略)?

想象一下,我有这个(或更复杂的场景,有数百个文件夹和数十个.gitignore文件:

/
-.gitignore
-folder/
    -.gitignore
    -subfolder/
              -.gitignore
              -file.txt
Run Code Online (Sandbox Code Playgroud)

如果我运行git add folder/subfolder/file.txtgit可能会抱怨它被忽略:

The following paths are ignored by one of your .gitignore files:
folder/subfolder/file.txt
Use -f if you really want to add them.
Run Code Online (Sandbox Code Playgroud)

有没有办法知道哪一个可能.gitignore有规则忽略这个文件,还显示规则?喜欢:

The following paths are ignored by your folder/.gitignore file (line 12: *.txt)
folder/subfolder/file.txt
Use -f if you really want to add them.
Run Code Online (Sandbox Code Playgroud)

要不就:

$ git why-is-ignored folder/subfolder/file.txt
folder/.gitignore:12:*.txt
Run Code Online (Sandbox Code Playgroud)

git gitignore

291
推荐指数
4
解决办法
4万
查看次数

Gitignore排除所有子目录中的某些文件

我有一个名为/ static的目录.它中有很多子目录.我需要忽略/ static /目录的所有子目录中的所有文件,除了.htaccess,null.jpg和index.php文件.请告诉我这个操作的正确语法是什么?

/static/**
!/static/**/.htaccess
Run Code Online (Sandbox Code Playgroud)

/static/*
!/static/*/.htaccess
Run Code Online (Sandbox Code Playgroud)

不工作.

git gitignore

6
推荐指数
1
解决办法
3680
查看次数

标签 统计

git ×4

gitignore ×4