Git

gitignore

CS349 teacher recommended this site to generate them https://www.toptal.com/developers/gitignore.

However, I like to just generate them with GitHub when I create a new project and choose a language.

Danger

One of the things you have to be careful with is that if you add a file/folder to a gitignore after the file/folder has been committed, it won’t ignore it.

Ignoring files that are already tracked

What if you track a file, then want to ignore it later?

  • i.e. you forgot to ignore it when setting up your repo

Files already tracked are not affected by changes to .gitignore

If you want to ignore a file that was tracked by accident

git rm --cached [filename]
git add -all
git commit -m "removed files tracked by mistake"

If you want to ignore all files that were tracked by accident:

git rm --cached -r [directory]
git add -all
git commit -m "cleaning files that should have been ignored"