1

I try to ignore .idea directory when commit and push to remote repository. I set my .gitignore file in following way:

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

But when I committed and pushed to tfs repository, I found the .idea folder is still pushed to repo.

Is there anyway to remove .idea folder from repository and ignore it in future commit and push?

Note: I have already committed and pushed to remote repository without setting up .gitignore file. I think the .idea folder in repo is from last commit.

enter image description here

Henry Bai
  • 367
  • 1
  • 3
  • 17
  • 1
    It's ignoring _changes_. It won't remove files you already committed. – jonrsharpe Jan 10 '23 at 21:24
  • 1
    Did you `git rm` that directory? Or if you want it to stay locally, see https://stackoverflow.com/questions/1143796/remove-a-file-from-a-git-repository-without-deleting-it-from-the-local-filesyste – Eugene Sh. Jan 10 '23 at 21:24
  • 1
    You can remove the folder anytime you like to prevent it from appearing in *future* commits. Removing it from *past* commits requires quite a bit of intrusive history editing. – chepner Jan 10 '23 at 21:25
  • 1
    `git rm --cached .idea` stages the directory (specifically, all files contained *in the directory*, which is all Git cares about) for removal without removing the directory itself from the working directory. – chepner Jan 10 '23 at 21:28
  • @jonrsharpe could you tell me how to resolve it please? I have no experience setting gitignore before – Henry Bai Jan 11 '23 at 04:20
  • @chepner Thanks! it works. idea removed from git repository, and after I pushed it to remote, idea removed from remote repository as well. – Henry Bai Jan 11 '23 at 04:35

0 Answers0