git ignore command code example

Example 1: gitignroe remove folder

git rm -r --cached some-directory
git commit -m 'Remove the now ignored directory "some-directory"'
git push origin master

Example 2: .gitignore

node_modules
.DS_Store
.env

Example 3: how to put files into gitignore

$ echo debug.log >> .gitignore
$ git rm --cached debug.log
rm 'debug.log'
$ git commit -m "Start ignoring debug.log"

Example 4: gitignore folder

in .gitignore:
	folder/

Example 5: git exclude folder

directory_to_exclude/

Example 6: how to git ignore a file

git config --global core.excludesfile ~/.gitignore_global