Skip to content

Instantly share code, notes, and snippets.

@bathivinod
Created July 10, 2023 12:37
Show Gist options
  • Select an option

  • Save bathivinod/efbff81960e6e29e761f78644b113a5d to your computer and use it in GitHub Desktop.

Select an option

Save bathivinod/efbff81960e6e29e761f78644b113a5d to your computer and use it in GitHub Desktop.
How to untrack a file that has already been committed to repo after adding to .gitignore

How to Untrack a File That Has Been Committed

It is IMPORTANT to note that you MUST COMMIT ALL PREVIOUS CHANGES BEFOE CONTINUING

  1. Remove everything from Local Repo git rm -r --cached . or if you are untracking a specific file(s) git rm -r --cached name_of_file

  2. Add back all untracked files git add .

  3. Commit Changes git commit -m "untrack name_of_file fix"

  4. Push changes to remote repo git push




If you have any questions, do not hesitate to contact me on social media.

Happy coding 😄, --Vinod

GitHub Twitter linkedin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment