create a git ignore file code example

Example 1: create gitignore

# creates gitignore file
$ touch .gitignore

Example 2: gitignroe remove folder

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

Example 3: create .gitignore

$ touch .gitignore

Example 4: create gitignore files

#Linux
$ touch .gitignore

#Windows
cd c:\<your path>
notepad .gitignore
#Accept the prompt to create the file, edit the contents accordingly, save and close.

Example 5: how to generate a .gitignore

echo "function gi() { curl -L -s https://www.gitignore.io/api/\$@ ;}" >> ~/.bash_profile && source ~/.bash_profile

Example 6: 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"