I have a folder which I'd like to remove in my remote repository. I'd like to delete it, but keep the folder in my computer
The easiest way to delete a file in your Git repository is to execute the “git rm” command and to specify the file to be deleted. Note that by using the “git rm” command, the file will also be deleted from the filesystem.
git rm will not remove a file from just your working directory. (There is no option to remove a file only from the working tree and yet keep it in the index; use /bin/rm if you want to do that.)
"git rm --cached <file>" would remove <file> from version control, while keeping it in the working repository.
git rm --cached -r somedir
Will stage the deletion of the directory, but doesn't touch anything on disk. This works also for a file, like:
git rm --cached somefile.ext
Afterwards you may want to add somedir/
or somefile.ext
to your .gitignore
file so that git doesn't try to add it back.
I would just:
git rm
the folder, commit the change.gitignore
(or .git/info/excludes
), commit the changeIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With