I know that if I want to ignore folder that I don't want to push to Github. I could use .gitignore
to ignore it.
Now my situation is I had pushed the folder up to Github, now I wish I could ignore it and delete it on Github, but still want the folder in local side.
How could I achieve it?
Using the git rm –cached Command We've mentioned that git rm FILE will remove files from the index and local working tree by default. However, the git rm command provides the –cached option to allow us only to remove files from the repository's index and keep the local file untouched. As we can see, the user-list.
Browse to the directory in the repository and branch that you want to delete. In the top-right corner, click "…", and then Delete directory.
Command line Git repository delete Just run the rm command with the -f and -r switch to recursively remove the . git folder and all of the files and folders it contains.
The folder is created when the project is initialized (using git init ) or cloned (using git clone ). It is located at the root of the Git project repository. If we delete the . git folder, the information saved by Git will be lost, and the directory will no longer act as a Git repository.
It seems like the --cached
option of git rm is what you want.
git rm --cached fileToDelete
git commit master
git push origin master
Now add the file to .gitignore
Not tested though.
In order for you to remove the folder or file from Github but no from you computer use this command in the following order
name-of-the-folder
"insert your comment inside this quotation marks"
in case you have several branches
you can do
master
branchName
EXAMPLE
git rm -r --cached .vscode
git commit -m "removed the .vscode folder"
git push origin
If 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