Skip to content

Instantly share code, notes, and snippets.

@akhilome
Last active April 13, 2019 12:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akhilome/b470afbdb8651d14323b1f9c1da97219 to your computer and use it in GitHub Desktop.
Save akhilome/b470afbdb8651d14323b1f9c1da97219 to your computer and use it in GitHub Desktop.
Remove accidentally committed files from git

Add files to be forgotten to your .gitignore file:

echo "[filename1.ext] \n[filename2.ext] \n[evenafulldirectory/]" >> .gitignore

From root of the repo run:

git rm -r --cached . > /dev/null && git add --all

Then commit changes:

git commit -m "remove gitignored files"

Or if you don't want to add a new commit:

git commit --amend --no-edit

Note: The last command appends the new changes to the last commit(!)

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