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?
Asked
Active
Viewed 271 times
5
-
Would http://stackoverflow.com/questions/2014422/hooks-for-git-svn help here? – VonC Oct 24 '12 at 07:03
-
isn't just dcommit following the global config rule that states that when you push it will sync all branches or only the current branch (depending on conf) ? – v.oddou Mar 11 '13 at 06:21
-
@v.oddou: No, it does not. dcommit does not use the configuration settings for `git push` (though one might argue that it should). – sleske Oct 02 '13 at 15:21
-
possible duplicate of [How can I avoid an accidental dcommit from a local branch](http://stackoverflow.com/questions/9226528/how-can-i-avoid-an-accidental-dcommit-from-a-local-branch) – sleske Dec 17 '13 at 13:52
1 Answers
0
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

snipsnipsnip
- 2,268
- 2
- 33
- 34