4

I pushed my code without putting .idea/ in .gitignore. But now when I realised it, I saw this SO answer. So when I tried to undo that commit/push using this SO answer, it works. But after adding .idea/* to .gitignore, and then doing git add and pushing the code, the .idea directory appears again and I can see all my previous commits(which I did undo).

What to do now?

Community
  • 1
  • 1
rahulserver
  • 10,411
  • 24
  • 90
  • 164

1 Answers1

10

It appears again because you didn't ignore the .idea folder. You ignored the .idea folder content.

To ignore the whole folder, your .gitignore should contain:

.idea/

If the .idea folder remains, I would suggests removing it from the index (not from the disk with the --cached option) and pushing a new commit recording that deletion:

git rm --cached -r .idea/
git add -A .
git commit -m "Delete .idea"
git push
Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks @VonC. But I tried this too before idea/*. The problem looks like that although i undid my previous commit from remote, but its still there in my local repo. This commit contains the idea folder. So unless this commit is erased, successive pushes would push this one also, thereby pushing the idea folder. – rahulserver Oct 26 '14 at 07:23