Detecting branch switches

Hi all,

is there way to get notified about a branch switch? Usually, i use git on command line an i'd like to be able to start some actions in my plugin in case the branch is switched.

Thanks in advance


For Git, you can use the GitRepositoryChangeListener interface and keep track of the return value of GitRepository.getCurrentBranch().


Hi Dmitry,
thx for your quick reply :)

So my plugin would have to depend on the git4idea plugin? How would i express this dependency in the plugin.xml?


Yes. The dependency tag would be <depends>Git4Idea</depends>
You'll also need to add the jars of the Git plugin to the classpath of your IntelliJ IDEA SDK.


Please sign in to leave a comment.