gitignore example

Example 1: reinit gitignore

# rm all files
git rm -r --cached .
# add all files as per new .gitignore
git add .
# now, commit for new .gitignore to apply
git commit -m ".gitignore is now working"

Example 2: create gitignore

# creates gitignore file
$ touch .gitignore

Example 3: gitignroe remove folder

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

Example 4: git add gitignore

$ touch .gitignore

Example 5: .gitignore

node_modules
.DS_Store
.env

Example 6: how to use gitignore to ignore a folder

You can ignore entire directories, just by including their paths and putting a / on the end:

1
2
node_modules/
logs/