1

I have a file (example: src/test.txt) which wasn't ignored before. But I'm ignoring it now (.gitignore on parent folder). If I do a git clone, this ignored file is included in the download.

Is there a way to somehow delete this file from git? I've searched the net but found nothing. I'm unsure what search criteria to use.

There are no branches in my repository.

edit: as a test, I created a new repository. ran "git add ." to add all files and then commit and pushed it. I then cloned the new repo and the ignored file is not listed.

Cœur
  • 37,241
  • 25
  • 195
  • 267
mrjayviper
  • 2,258
  • 11
  • 46
  • 82
  • 5
    Use `git rm --cached ` – Tim Biegeleisen Aug 25 '16 at 02:57
  • @TimBiegeleisen Hi Tim. I just tried that command. then did a git push. I got an "all up to date" message. I then went to my remote host. Performed a git clone and the file is still there. I just confirmed again the file is in my .gitignore. – mrjayviper Aug 25 '16 at 03:17
  • as a test, I created a new repository. ran "git add ." to add all files and then commit and pushed it. I then cloned the new repo and the ignored file is not showing. – mrjayviper Aug 25 '16 at 03:23
  • See http://stackoverflow.com/questions/936249/stop-tracking-and-ignore-changes-to-a-file-in-git or http://stackoverflow.com/questions/1143796/remove-a-file-from-a-git-repository-without-deleting-it-from-the-local-filesyste (or http://stackoverflow.com/questions/1273108/how-do-i-git-rm-a-file-without-deleting-it-from-disk) – Edward Thomson Aug 25 '16 at 03:33

1 Answers1

2

Tim Biegeleisen say the correct way, maybe you forgot the

git commit -m 'delete file'

and

git push

after

git rm --cached <file> 
manhattan
  • 133
  • 2
  • 10
  • I've already commited and pushed several changes since I've edited my .gitignore – mrjayviper Aug 25 '16 at 03:33
  • Maybe this answer can help you on you original question http://stackoverflow.com/questions/13541615/how-to-remove-files-that-are-listed-in-the-gitignore-but-still-on-the-repositor – manhattan Aug 25 '16 at 03:37