I have accidentally committed the .idea/
directory into git. This is causing conflicts everywhere else I need to checkout my repo. I was wondering how do I remove these files from the remote?
I still need these files locally since the Intellij IDE needs them. I just don't want them in the remote. I have added the directory .idea/
to my .gitignore
and committed and pushed this file into remote. This seems to have no effect during my checkout on my other machine though. I still get the error message:
error: The following untracked working tree files would be overwritten by checkout:
.idea/.name
.idea/compiler.xml
.idea/copyright/profiles_settings.xml
.idea/encodings.xml
.idea/misc.xml
.idea/modules.xml
.idea/scopes/scope_settings.xml
.idea/uiDesigner.xml
.idea/vcs.xml
.idea/workspace.xml
This question is related to
git
Its better to perform this over Master branch
Edit .gitignore file. Add the below line in it.
.idea
Remove .idea folder from remote repo. using below command.
git rm -r --cached .idea
For more info. reference: Removing Files from a Git Repository Without Actually Deleting Them
Stage .gitignore file. Using below command
git add .gitignore
Commit
git commit -m 'Removed .idea folder'
Push to remote
git push origin master
You should add a .gitignore file to your project and add /.idea
to it. You should add each directory / file in one line.
If you have an existing .gitignore file then you should simply add a new line to the file and put /.idea
to the new line.
After that run git rm -r --cached .idea
command.
If you faced an error you can run git rm -r -f --cached .idea
command. After all run git add .
and then git commit -m "Removed .idea directory and added a .gitignore file"
and finally push the changes by running git push
command.
You can remove it from the repo and commit the change.
git rm .idea/ -r --cached
git add -u .idea/
git commit -m "Removed the .idea folder"
After that, you can push it to the remote and every checkout/clone after that will be ok.
Source: Stackoverflow.com