Skip to content

Instantly share code, notes, and snippets.

@maya257
Last active November 13, 2023 11:01
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maya257/1b2718054b65f4720fa582c6a4032217 to your computer and use it in GitHub Desktop.
Save maya257/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 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 😄, --Maya

GitHub Twitter linkedin

@livie99
Copy link

livie99 commented Aug 24, 2023

Thx, this is so helpful!!!<3<3<3

@Ilbashyr09
Copy link

  • same here, ### ### we appreciate

@agabaandre
Copy link

Follow this example: Add the file to .gitignore to be untracked
Then run
git rm -r --cached C:/xampp/htdocs/staff/application/config/database.php

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