Remove commited file from git repo keeping local copy
- Create a
.gitignoreif you have not one already
.gitignoreand add the path/to/file
git -rm --cached path/to/file. All the removed files will be listed. The
--cachedfile specifies that you want to remove it from repository but keep the local copy. Also you can use
-rflag to remove files recursively.c
git-statusto verify the changes.
- Push the code to repository using
Note: while you ignored those files from repository, they can still be viewed from history. Thus if you want them to be excluded from history as well, make sure you remove them from Git History.