[英]gitignore not working - want to ignore everything but gitignore file to keep an 'empty' directory
我在幾個目錄(例如log/
)中有一個.gitignore
文件,其中包含以下內容:
* " Ignore everything in this directory
!.gitignore " Except this file
盡管如此,如果該目錄中有一個文件, git status
會向我顯示它是新的但未跟蹤。
# On branch master
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# log/blah.log
nothing added to commit but untracked files present (use "git add" to track)
我發現stackoverflow上的其他帖子建議在第一行和各種其他形式或隨機伏都教上發表評論,但沒有任何效果。
簡單地說,我想在我的倉庫中存在一個tmp/
和log/
目錄,但是空的。 我不希望任何人被騷擾將他們的日志和tmp文件添加到這些目錄。
你期望雙引號在你的.gitignore
文件中表現得像一個評論嗎? 你有這個......
* " Ignore everything in this directory
!.gitignore " Except this file
......但那就是你想要的。 如果你簡單地替換它:
*
!.gitignore
它會工作得很好。 看:
$ ls -A
dir1 .git
$ ls -A dir1
.gitignore
$ cat dir1/.gitignore
*
!.gitignore
$ git status
# On branch master
nothing to commit (working directory clean)
$ touch dir1/file{1,2,3}
$ ls -A dir1
file1 file2 file3 .gitignore
$ git status
# On branch master
nothing to commit (working directory clean)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.