Git by Examples
.gitignore and how to untrack file
To untrack file changes do the following steps:
1. vim .gitignore
a) If you want to exclude specific file enter:
/settings/file.js
or
setings/file.js
b) If you want to exclude all files in directory
settings/*
c) if you want to exclude all files but not one file:
setings/*
!settings/file.js
tmp/*
tmp/sessions/*
tmp/logs/*
tmp/logs/crawler/*
tmp/logs/winston/*
exceptions.log
npm-debug.log
settings/*
!settings/main.js
Notice that the gitignore current folder is where is .gitignore file settled.
Possible problems
If .gitignore don't work as expected do the following:
1. First commit all changes or you will lose them
2. Do the commands
git rm . -r --cached
git add .
git commit -m "fixed untracked files"
Notice:
git-rm - Remove files from the working tree and from the index