Skip to content

Instantly share code, notes, and snippets.

@mcrd25
Last active June 14, 2025 21:19
Show Gist options
  • Select an option

  • Save mcrd25/1b2718054b65f4720fa582c6a4032217 to your computer and use it in GitHub Desktop.

Select an option

Save mcrd25/1b2718054b65f4720fa582c6a4032217 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 you need git add . or git add name_of_file_with_fix

  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 😄, --Maya

GitHub linkedin

@ArthurV7
Copy link

@mcrd25 oohhh I understand, thx for the help.

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