How can I avoid an accidental dcommit from a local branch

前端 未结 3 543
孤独总比滥情好
孤独总比滥情好 2020-12-10 15:10

Sometimes, I create local branches in git, and I\'d like to get a warning message when I try to dcommit from them.

How can I prevent myself from accidentally dcommit

3条回答
  •  心在旅途
    2020-12-10 15:33

    First thing that comes in mind is using a git pre-commit hook to solve the problem. This would be easy for pure git repos:

    • Lock remote branches (update hook): Is there a way to lock a branch in GIT
    • Lock local branches (pre-commit hook): Locking a branch, so that it cannot be staged/committed into? (Only merged/etc)

    But as discussed in Hooks for git-svn, this isn't fully working. VonC came up with an (accepted) answer where he utilizes an intermediate bare repo that acts like kind of a proxy between git ans SVN.

    Maybe this could help you too.

提交回复
热议问题