Follow the below mentioned steps if you want to ignore certain files from your git repository.
- Navigate to the location of your Git repository.
- Type "
touch .gitignore" and press enterto create a .gitignore file.
Note: If you are adding .gitignore to an existing repository.
Execute git rm --cached name_of_file to remove files that you do not want to be tracked. This is required because
.gitignore ignores files that were not tracked before (by git add)Example:
If you want to ignore all log files from your logs directory. Enter below line to your .gitignore file
logs/*