1

I have seen this post about no longer tracking a previously tracked file, but here is my situation.

I previously committed a directory. I now want to untrack everything in that directory but still track the directory itself.

I have added /auto-save-list/* to the .gitignore file (the directory I am trying to ignore is the auto-save-list directory in the root of the project, and I have run git rm --cached but I still have multiple filed from that directory that show up as new when I go to make a commit. Similarly the files show up in my origin repo.

Can someone help me ignore the contents of the previously tracked file?

Community
  • 1
  • 1
Startec
  • 12,496
  • 23
  • 93
  • 160
  • 4
    Git doesn't track directories, only files. If you untrack everything in that directory, the directory too vanishes, unless you put a file in there. – Makoto Jun 14 '15 at 02:31

1 Answers1

1

This should be enough:

git rm -r --cached auto-save-list/
echo "/auto-save-list/" > .gitignore
git add .gitignore
git commit -m "Records untracking of /auto-save-list/ folder"

No need for '*'

If you still need the directory to be there (versioned in the Git repo, even though Git doesn't track an empty folder), add a dummy file in it.

touch auto-save-list/.keep
git add -f auto-save-list/.keep
git commit -m "Record auto-save-list/ folder, while ignoring its content"
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250