.gitignore not ignoring .idea path

2019-03-07 15:46发布

What am I missing that needs to be done in order to get git to ignore my .idea/ path?

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/

标签: git gitignore
5条回答
▲ chillily
2楼-- · 2019-03-07 16:12

For those of you getting fatal: pathspec '.idea' did not match any files with w0lf's answer:

You just have to include the full path to the .idea folder.

So first, do a git status, which should show you the path to .idea given where you currently are.

Then, include the path in the command w0lf suggested: git rm --cached -r example/path/to/.idea

查看更多
混吃等死
3楼-- · 2019-03-07 16:15

add .idea/ to .gitignore file

run this commands in terminal to complete mission :)

git rm -rf .idea
git commit -m "delete .idea"
git push
查看更多
唯我独甜
4楼-- · 2019-03-07 16:15

To Solve Error "fatal: pathspec '.idea' did not match any files" after entering above command,

  1. Check the path of your idea folder and its files.
  2. 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
  3. Modify the above suggested command in the accepted answer to git rm --cached -r ../.idea
  4. You will then see this rm '.idea/workspace.xml' and the files will be removed.
查看更多
叼着烟拽天下
5楼-- · 2019-03-07 16:22

To remove the "fatal: pathspec '.idea' did not match any files" just use if the dir still returns as untracked:

git clean -f -d .idea

查看更多
Emotional °昔
6楼-- · 2019-03-07 16:27

.gitignore only ignores newly added (untracked) files.

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.

To remove that folder from the repository (without deleting it from disk), do:

git rm --cached -r .idea
查看更多
登录 后发表回答