相关疑难解决方法(0)

Git diff不会忽略.gitignore中的指定文件

我是git的新手,我不知道我做错了什么.我想运行git diff --name-only但我想要排除以.test结尾的文件,这意味着即使这些已经改变了,我也不希望git diff输出它已被更改.我试图将这些文件添加到.gitignore文件中,但是当我运行git diff命令时,所有这些都包括.gitignore!

我做错了什么以及如何在运行git diff时排除文件?

git batch-file

10
推荐指数
1
解决办法
4522
查看次数

尽管在.gitignore中,.DS_Store仍然以git状态出现

$ cat .gitignore 

# OSX
*/.DS_Store
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
Icon?
ehthumbs.db
Thumbs.db

$ git status
On branch develop
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:   Assets/Sprites/.DS_Store

no changes added to commit (use "git add" and/or "git commit -a")
Run Code Online (Sandbox Code Playgroud)

现在.gitignore和状态消息中有更多不相关的文件,但.gitignore本身未被修改,此版本已提交.

我该如何解决这个问题?

git gitignore

10
推荐指数
2
解决办法
3696
查看次数

标签 统计

git ×2

batch-file ×1

gitignore ×1