search

Home  >  Q&A  >  body text

git 无法删除 .idea 目录

根目录下有一个 .idea 文件夹,我已经在 根目录下的 .gitignore 文件中加入了

.idea/*
.idea*
\.idea*

然后 git commit -m "ignore .idea dir" -> git push -u origin ->
但是远程的git 中还是有 .idea 这个目录。无法删除。

Administrator@PC-20140703LOZL /D/PC/ppgame (master)
$ git rm --cached .idea/*
fatal: pathspec '.idea/encodings.xml' did not match any files

Administrator@PC-20140703LOZL /D/PC/ppgame (master)
$ git rm --cached .idea
fatal: pathspec '.idea' did not match any files

Administrator@PC-20140703LOZL /D/PC/ppgame (master)
$ git rm --cached .idea/*.*
fatal: pathspec '.idea/encodings.xml' did not match any files

Administrator@PC-20140703LOZL /D/PC/ppgame (master)
$ git rm --cached .idea*
fatal: pathspec '.idea' did not match any files

Administrator@PC-20140703LOZL /D/PC/ppgame (master)
$ git rm --cached \.idea*
fatal: pathspec '.idea' did not match any files

1)如何才可以删除git中跟踪的 .idea目录但是又不删除本地的 .idea 文件夹?
2)是不是遇到文件夹中有. 这样特殊字符的,在.gitignore中需要转义?


我使用了 git rm -r --cached .idea 但是报错,删除不了。远程还在


Administrator@PC-20140703LOZL /D/PC/ppgame (master) $ git rm -r --cached .idea fatal: pathspec '.idea' did not match any files Administrator@PC-20140703LOZL /D/PC/ppgame (master) $ git push -u orign --all fatal: 'orign' does not appear to be a git repository fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. Administrator@PC-20140703LOZL /D/PC/ppgame (master) $ git push -u orign/master --all fatal: 'orign/master' does not appear to be a git repository fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. Administrator@PC-20140703LOZL /D/PC/ppgame (master) $
怪我咯怪我咯2772 days ago1093

reply all(5)I'll reply

  • 世界只因有你

    世界只因有你2017-04-27 09:05:44

    You need to delete the remote .idea directory first.

    In this case, you didn’t consider it before designing gitignore. The current measures are:

    rm -rf .idea (This will delete your local one, but it will be automatically generated for you if you reopen the project)

    git add -A .
    Submit
    git pull

    Pull and check again after synchronization to see if the remote ones have been deleted; if there are local ones, repeat again.

    After cleaning, run git rm -r --cached .idea to cancel tracking
    Let’s push

    reply
    0
  • phpcn_u1582

    phpcn_u15822017-04-27 09:05:44

    Files already tracked by git cannot be written in the gitignore file.

    reply
    0
  • 怪我咯

    怪我咯2017-04-27 09:05:44

    1. .gitignore 先不添加忽略的那行,直接删除 .idea file and submit
    2. Open .gitignore 里添加 .idea/*
    3. Submit .gitignore, over

    reply
    0
  • PHPz

    PHPz2017-04-27 09:05:44

    1. Use git rm -fr .idea to delete local .idea files,

    2. Add .idea to the .gitignore file for filtering

    3. Save and submit to the remote end, and then you find that it has been cleared

    reply
    0
  • 迷茫

    迷茫2017-04-27 09:05:44

    # The execution steps are as follows:

    1. Add .idea/ to the file first. ignore file.
      2. Delete local. idea file

    3.git add.

    1. git commit -m "update .ignore file"

    2. git push origin master
      6. Open the file with the local idea, and you will see that the local .idea file is back.

    reply
    0
  • Cancelreply