Skip to content

Instantly share code, notes, and snippets.

@cyberfly
Last active November 28, 2017 06:39
Show Gist options
  • Select an option

  • Save cyberfly/49f02ea986bb5a9b42c5ad23b3248ed5 to your computer and use it in GitHub Desktop.

Select an option

Save cyberfly/49f02ea986bb5a9b42c5ad23b3248ed5 to your computer and use it in GitHub Desktop.
GIT remove file from commit https://stackoverflow.com/a/30360954/417899
NOTE: THIS ONE WILL NOT REMOVE THE FILE FROM MASTER REPO, BUT REMOVE FROM CHANGES
git checkout origin/master <path_to_file>
WARNING : This will remove file from your MASTER REPO!!
I came across this question while Googling for "git remove folder from tracking". The OP's question lead me to the answer. I am summarizing it here for future generations.
Question
How do I remove a folder from my git repository without deleting it from my local machine (i.e., development environment)?
Answer
Step 1. Add the folder path to your repo's root .gitignore file.
path_to_your_folder/
Step 2. Remove the folder from your local git tracking, but keep it on your disk.
git rm -r --cached path_to_your_folder/
Step 3. Push your changes to your git repo.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment