One of the most abused commands in git has to be
git add .
and the least used files has to be .gitignore .
I will not go into details on how .gitignore works the docs http://git-scm.com/docs/gitignore cover it quite well, in summary the file specifies what files git should ignore.
If you are wondering what files to ignore, here are some clues.
IDE Meta Files
Almost all IDEs generate a special folder in your project to store the projects meta data. An example would be the nbproject folder for netbeans.
The entire directory needs to be ignored.
Images, Videos, Documents and other binary files
This are generally user generated contented and not code. Version controlling this assets will lead to unnecessary bloat.
Furthermore if you use github there are limits to the size of the files https://help.github.com/articles/what-is-my-disk-quota .
Libraries that you use for your system an example would be the vendor folder automatically generated by composer https://getcomposer.org/ need to be ignored.
While this libraries are code, you did not write the libraries and have no reason to version it. If you are deploying using git then you can just as easily upload the libraries or run composer update on the remote server and get the same files once more.
Unless in edge cases you should never version the output of your code. eg CSV reports, logs, pdfs etc
This is because the data can be easily regenerated and even more importantly it is not part of your code.
If you are using a file based database system like SQLite. Make sure to ignore the database files. If you need a backup. You can setup automated backups separately.
In conclusion you can use this as a general rule of thumb
If you did not write it, don’t version it
Have any extra additions of your own? Please add to the comments section below.
Till next time. Happy coding!!