Git/Tips

A list of Git tips and tricks

Dealing with old branches
If you've been working with git for a while you probably have a bunch of old crufty branches laying around that you don't need anymore. The ones you definitely don't need anymore are ones that have already been merged back to master. You can identify these with:

Similarly, when submitting a change for review, you can have your branch automatically deleted once it's been merged by Gerrit:

Pre-commit checks
Git allows you to define checks a commit has to pass via hooks (see  for details). You should keep in mind that you have to define hooks separately for every (for example extension's) repository and that they are not copied by, so you have to create some procedure suiting your personal work patterns for how to keep them organized.

Start by enabling the pre-commit sample installed by Git. It disallows non-ASCII filenames and trailing whitespace.

Disallow commits to master
Committing to  in your local repository usually isn't what you want. To disable, put this sniplet at the top:

You could also disallow commits to other branches (REL1_20, etc.), but protecting against  is enough in most cases.

Run php -l on PHP files
It's probably a good idea to check whether any PHP files you added or changed pass a simple  test. To enable this, put this sniplet before the final  line:

View source code

 * View "core" source code