Ignoring Files In Git

by Devansh


Posted on 20 Mar 2018 11:03:25 (4 months ago)


Now a days, for developer Version Controlling is very important to maintain their codes. So, there are some files which developer doesn't want to go in the the git repository so to avoid this case there is ignore file feature in Git. We just need to create a file named as '.gitignore' and put the file path of that file which we want to ignore. I am sharing some steps and commands which I use in my daily life. These commands are for Linux.

1. touch .gitignore

2. Add file you want to ignore by git in .gitignore

Note: If file is already tracked then you have to do the following steps more,
Let say example1.txt file is tracked. Then you have to remove it from git first.

3. git rm --cached example1.txt

4. git add .

5. git commit -m "Some Files Are Ignored"

6. git push -u origin master

The changes will occur in next commit from head revision.