git-cheatsheet icon indicating copy to clipboard operation
git-cheatsheet copied to clipboard

Making git "forget" about all files that are already tracked but are in .gitignored

Open madc opened this issue 11 years ago • 5 comments

http://stackoverflow.com/a/19095988/709769

Remove all files from repo:

git rm -r --cached . 

Re-add all files:

git add .

then

git commit -am "Remove ignored files"

madc avatar Jan 08 '14 12:01 madc

@madc perfect I would phrase it more like this question though.

Applying .gitignore to committed files

  • Edit .gitignore to match the file you want to ignore
  • git rm --cached /path/to/file

trufa avatar Jan 08 '14 12:01 trufa

There is a difference between the two posts. Mine takes care of removing all files that are listed in the .gitignore. Sticking with the answer referenced by you, you still have to remove all files separately (i.e. node_modules/* and .idea/*)

madc avatar Jan 08 '14 13:01 madc

I disagree! Dot (.) is a path like anyone else, just means the current directory.

trufa avatar Jan 08 '14 13:01 trufa

That's true, but than your answer is only showing half the workflow.

Edit: Just realized, that the topic did not really said, what i wanted to do. Renamed it.

madc avatar Jan 08 '14 13:01 madc

Hmm, you're right, that's a better flow.

I like my title better though... (I have to win one at least)

trufa avatar Jan 09 '14 12:01 trufa