.gitignore 的正确用法(针对文件类型)
correct usage of .gitignore (for file types)
当我键入 git 状态时,我收到以下消息:
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: .DS_Store
modified: README.txt
modified: lib/PriceSeries.rb
Untracked files:
(use "git add <file>..." to include in what will be committed)
MM8 Prices.pdf
prices from EH.xlsx
我希望能够说 git add .
,而不添加未跟踪的文件。我相信 .gitignore 文件应该是为了这个。我的 .gitignore 文件(在 .git 文件夹中)如下所示:
#Ignore all xlsx files
.xlsx
#Ignore all pdf file
.pdf
我做错了什么?
为您的扩展添加前缀 *
:
#Ignore all xlsx files
*.xlsx
#Ignore all pdf file
*.pdf
[更新] 另外,.gitignore
必须在项目的根目录下,而不是在 .git
下
当我键入 git 状态时,我收到以下消息:
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: .DS_Store
modified: README.txt
modified: lib/PriceSeries.rb
Untracked files:
(use "git add <file>..." to include in what will be committed)
MM8 Prices.pdf
prices from EH.xlsx
我希望能够说 git add .
,而不添加未跟踪的文件。我相信 .gitignore 文件应该是为了这个。我的 .gitignore 文件(在 .git 文件夹中)如下所示:
#Ignore all xlsx files
.xlsx
#Ignore all pdf file
.pdf
我做错了什么?
为您的扩展添加前缀 *
:
#Ignore all xlsx files
*.xlsx
#Ignore all pdf file
*.pdf
[更新] 另外,.gitignore
必须在项目的根目录下,而不是在 .git