根目录下有一个 .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)
$
Vous devez d'abord supprimer le répertoire .idea distant.
Dans ce cas, vous n'y avez pas pensé avant de concevoir gitignore. Les mesures actuelles sont :
rm -rf .idea (Cela supprimera votre projet local, mais il sera automatiquement généré pour vous si vous rouvrez le projet)
git add -A .
Soumettre
git pull
Après avoir extrait, vérifiez si les distants ont été supprimés après la synchronisation ; s'il y en a des locaux, répétez à nouveau.
Après le nettoyage, exécutez git rm -r --cached .idea pour annuler le suivi
Poussons
Les fichiers déjà suivis par git ne peuvent pas être écrits dans le fichier gitignore.
.gitignore
N'ajoutez pas d'abord la ligne ignorée, supprimez le fichier.idea
directement, puis soumettez.gitignore
et ajoutez.idea/*
.gitignore
, terminéUtilisez
git rm -fr .idea
pour supprimer le fichier .idea local,Ajoutez .idea au fichier .gitignore pour filtrer
Enregistrez et soumettez à l'extrémité distante, puis vous constatez qu'il a été effacé
# Les étapes d'exécution sont les suivantes :
Ajoutez d'abord .idea/ au fichier. ignorer le fichier.
2. Supprimer le local. fichier idée
3.git ajouter.
git commit -m "mettre à jour le fichier .ignore"
git push origin master
6. Ouvrez le fichier avec l'idée locale et vous verrez que le fichier .idea local est de retour.