git .gitignore 不忽略 .idea 路径
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32384473/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
.gitignore not ignoring .idea path
提问by MrDuk
What am I missing that needs to be done in order to get git
to ignore my .idea/
path?
为了git
忽略我的.idea/
路径,我错过了什么需要做的事情?
ctote@ubuntu:~/dev/1$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
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: .idea/.name
modified: .idea/misc.xml
modified: .idea/modules.xml
modified: .idea/vcs.xml
modified: .idea/workspace.xml
modified: src/Receiver.java
modified: test/1/agent/WindowsQueryHandlerTest.java
Untracked files:
(use "git add <file>..." to include in what will be committed)
lib/
mp1.iml
no changes added to commit (use "git add" and/or "git commit -a")
ctote@ubuntu:~/dev/1$ cat .gitignore
*.class
# Package Files #
*.war
*.ear
# IDEA config files
.idea/
回答by Cristian Lupascu
.gitignore
only ignores newly added (untracked) files.
.gitignore
只忽略新添加(未跟踪)的文件。
If you have files that have already been added to the repository, all their changes will be tracked as usual, even if they are matched by .gitignore rules.
如果您有已添加到存储库中的文件,则它们的所有更改都将照常跟踪,即使它们与 .gitignore 规则匹配。
To remove that folder from the repository (without deleting it from disk), do:
要从存储库中删除该文件夹(而不从磁盘中删除它),请执行以下操作:
git rm --cached -r .idea
回答by do01
add .idea/
to .gitignore file
添加.idea/
到 .gitignore 文件
run this commands in terminal to complete mission :)
在终端中运行此命令以完成任务:)
git rm -rf .idea
git commit -m "delete .idea"
git push
回答by Randomize
To remove the "fatal: pathspec '.idea' did not match any files"just use if the dir still returns as untracked:
要删除“致命:pathspec '.idea' 与任何文件不匹配”,只需在目录仍以未跟踪状态返回时使用:
git clean -f -d .idea
git clean -f -d .idea
回答by Alex Totheroh
For those of you getting fatal: pathspec '.idea' did not match any files
with w0lf's answer:
对于那些得到fatal: pathspec '.idea' did not match any files
w0lf 回答的人:
You just have to include the full path to the .idea folder.
您只需要包含 .idea 文件夹的完整路径。
So first, do a git status
, which should show you the path to .idea
given where you currently are.
所以首先,做一个git status
,它应该显示.idea
你当前所在位置的路径。
Then, include the path in the command w0lf suggested: git rm --cached -r example/path/to/.idea
然后,在 w0lf 建议的命令中包含路径: git rm --cached -r example/path/to/.idea
回答by Josh Desmond
If, after following steps from other answers, you still find that your instance of git running in bash or powershell just keeps on tracking the .idea/ folder, then try this!
如果按照其他答案的步骤操作后,您仍然发现在 bash 或 powershell 中运行的 git 实例只是继续跟踪 .idea/ 文件夹,那么试试这个!
I discovered that Jet Brains IDE's have their own .gitignore, and run their own instance of git that will override your .gitignore settings!
我发现 Jet Brains IDE 有他们自己的 .gitignore,并运行他们自己的 git 实例来覆盖你的 .gitignore 设置!
What I did to fix this was to navigate to /.idea/.gitignore, and change its contents to:
我为解决这个问题所做的是导航到/.idea/.gitignore,并将其内容更改为:
/**
so as to ignore everything in the folder.
以便忽略文件夹中的所有内容。
The image below shows how you can navigate to the .gitignore file from within your Jetbrains IDE.
下图显示了如何从 Jetbrains IDE 中导航到 .gitignore 文件。
回答by Gautam Mandsorwale
To Solve Error "fatal: pathspec '.idea' did not match any files"after entering above command,
输入上述命令后解决错误“fatal: pathspec '.idea' did not match any files”,
- Check the path of your idea folder and its files.
- For this do
git status
. It will list all the files as usual. Check the path of idea folder files. Mine was at../.idea/workspace.xml
. Notice the../.idea
- Modify the above suggested command in the accepted answer to
git rm --cached -r ../.idea
- You will then see this
rm '.idea/workspace.xml'
and the files will be removed.
- 检查您的想法文件夹及其文件的路径。
- 为此做
git status
。它会像往常一样列出所有文件。检查idea文件夹文件的路径。我的是在../.idea/workspace.xml
。请注意../.idea
- 在接受的答案中修改上述建议的命令
git rm --cached -r ../.idea
- 然后您将看到这一点
rm '.idea/workspace.xml'
,文件将被删除。