using git ignore

gitignore is helpful when you want to ignore certain files (such as the config files) while working on the files checked out from a git repository. You do not want to commit the config files because other people working on the same repository would also pull your config files which is bad.

Why ignore? because it will be easier for you to go through the files that have been changed before committing. Usually, we do a “git status” before committing. By not ignoring the config files, they will show up in the status which can be annoying.

How do we implement git ignore?

just create a .gitignore file in any directory containing the files or directory that you want to ignore. for example we want to ignore wp-config.php and .htaccess in the root directory, add these 2 lines:


note: the slashes infront is important because we do not want to ignore files with similar names in the subdirectory. To ignore .htaccess in the css directory for example, we can either place /css/.htaccess under the root directory or create a new .gitignore file under the css directory and just put a /.htaccess in there.

if for some reason, gitignore doesnt ignore .htaccess for example (I did encounter this bug before), do

git update-index --assume-unchanged .htaccess

Author: bpeh

Bernard Peh is a great passioner of web technologies and one of the co-founder of Website Design and Reviews. He works with experienced web designers and developers everyday, developing and designing commercial websites. He specialises mainly in SEO and PHP programming.