Sanity check pre-commit hook for SVN

Authored by

When committing to SVN, “there is no reset button”. You cannot purge the memory of a commit once it has been made in an SVN repo (e.g. a theme on VIP, a plugin in the directory, or even especially WordPress core at That is, in SVN there is no commit amending, hard reset, or force push like in Git (git commit --amend && git push -f or git reset --hard HEAD^ && git push -f). For this reason, it is extra important to double and triple check SVN commits when you make them. In Git, a pre-commit hook can be installed which runs before the commit is made. While SVN also supports pre-commit hooks, there is no built-in client-side pre-commit hook facility: the SVN pre-commit hook has to be installed on the server, something that is usually not an option.

So here is another solution: create a Bash function that wraps around the svn command on your PATH. This function can show you the repo URL you are committing to as the first sanity check, followed by a list of the changed files to be committed, a countdown timer for good measure, and finally a Y/N prompt to proceed with the commit. Consider this svn Bash function:

Add this to your .bashrc or .bash_profile and the next time you do svn commit you’ll get an experience like this:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.