How to remove workspace.xml so that it is not indexed?

In .gitignore is written

 .idea/workspace.xml /.idea/workspace.xml .idea /.idea */.idea/workspace.xml 

but it is still indexed.

  • git rm -r --cached .idea - etki
  • @etki did the first commit as if deleting these files, but the next commit does not add and as if changes these files, there are 13 of them, that is, they are indexed again - J Mas
  • @eldqs, though? Where is the Gignor lying around? - etki
  • in the project folder in the root, it turns out that first it deleted, 13 files were written, 13 files were deleted and the second commit, it re-indexes and 13 files are changed, that is, the files that were deleted. - J Mas
  • @eldqs, these are the problems of the gigignor, apparently. I do not know why he ignores him, but for the first time, apparently, everything went ok. With the help of git status, you can see what git wants to do with the files on the next commit, it will also be visible there when the gigignor takes effect. - etki

2 answers 2

shorter version (only two commands changing something)

  1. recursively delete the directory from the repository (working copy is not affected - only the contents of the index are changed):

     $ git rm -r --cached .idea 

    Before git commit it is always useful to look at git status and make sure everything goes as it should:

     $ git status On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage) deleted: .idea/workspace.xml 
  2. everything is good. make commit . The working copy is also not affected - the content of the repository changes (everything that is in the .git directory):

     $ git commit ... 

check:

 $ ls .idea workspace.xml 

Yes, the file is in place.

and in .gitignore enough to leave one line (from all voiced in the question):

 .idea 
  • $ is not an internal or external command .. where do you enter "$ git rm -r --cached .idea"? - Sergey Shturnev
  • @SergeyShturnev, the dollar sign in this case means the shell prompt. the team itself is what comes after the dollar sign. - aleksandr barakin

Apparently, the files have already been made commit, will help

 mv .idea .idea1 git rm -r .idea git commit [--amend] mv .idea1 .idea 

Either edit the previously made git rebase -i ... and there git rm -r --cached .idea

  • 2
    And in order not to do mv twice, you can add --cached . - Nick Volynkin
  • I thought --cached only applies to changes prepared for a commit, but not, depending on whether the content matches - either from the index or from the branch. - sercxjo