Search code examples
git-svn

Is there a hook for git-svn that prevents from dcommit'ing branches?


I need some way to prevent myself from accidentally dcommitting local branches - except for master branch, of course. Is there an easy way to do that?


Solution

  • You can wrap git svn dcommit in an alias and add some test there.

    I'm using following alias in .gitconfig:

    [alias]
        safe-dcommit = "!f() { if test \"$(git symbolic-ref HEAD)\" != refs/heads/master; then echo You must be on master branch; else git svn dcommit \"$@\"; fi; }; f"
        dc = !git safe-dcommit