Reputation: 1019
I need to delete a directory of tracked files from my local working directory but not from the remote git server.
I tried git rm --cached
but it seems like it will commit those changes to the server. I want the files to remain tracked on the server.
Any help would be appreciated. Thanks
Upvotes: 3
Views: 1995
Reputation: 1325137
The problem with git rm
(with or without --cached
) is that it would stage the deletion of the directory in your local index, making it a possible candidate for a commit (which can be pushed by mistake, deleting the directory in the upstream repo as well)
You could try, within your directory:
git ls-files | tr '\n' '\0' | xargs -0 git update-index --assume-unchanged
(see more at "git update-index --assume-unchanged
on directory"), and then a simple non-git command:
rm -Rf yourDirectory
Your git repo should ignore the deletion, and it has no effect on the index.
Upvotes: 2
Reputation: 9749
I think you can try to ignore the files in your local git repo.
exclude them in
.git/info/exclude
Upvotes: 0