This question has already been answered:

I compiled a .gitignore file and put it in the root of the project. In the file there is an indication that you need to ignore the .idea/workspace.xml files.

# Intellij

* .iml

.idea / workspace.xml

.idea / libraries

But anyway, when I write git status I get

 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/workspace.xml 

What am I doing wrong?

Reported as a duplicate member Nick Volynkin Jul 6 '16 at 15:06 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

  • can be like this /.idea/workspace.xml ? - lexxl

2 answers 2

Line

 modified: .idea/workspace.xml 

says that the file is already in the index, it means that you first need to stop tracking

 git rm --cached .idea/workspace.xml 

Git rm

after that, if the file is correctly added to gitignore then with the command

 git status 

file should not be

Adding gitignore

 git add .gitignore git commit -m"gitignore was updated" gut push origin master 
  • And if I already did git add . and flooded everything, now you need to do so git rm --cached .idea / workspace.xml, then I do git commit -m and then git push? So? - Aleksey Timoshchenko 2:44 pm
  • after deleting from the index and adding to the titinor itself, the titignor file itself will modify and its (the titinner file) will need to be addressed - Maksym Semenykhin
  • fix the code with the addition of gitignore, see - Maksym Semenykhin

The .gitignore file .gitignore affects files that are new to the repository. Your .idea/workspace.xml file is already in the repository - and therefore continues to be tracked.

You need to delete it (or move it to another location), and then commit the deletion to the repository. After that, the old file can be returned to its place and git will no longer offer to add it.

  • Today I use gitom the first day, so sorry for early)) But if I understood correctly, then I have to do git rm --cached .idea/workspace.xml , then I do git commit -m and then git push ? So? - Aleksey Timoshchenko 2:41 pm