Tuesday, 30 June 2015

adding .gitignore file to existing repository


Follow the below mentioned steps if you want to ignore certain files from your git repository.
  1. Navigate to the location of your Git repository.
  2. Type "touch .gitignore" and press enter to 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/*