Get Drools saved branch on post-commit githook

71 Views Asked by At

I want to push all changes on a drools git repo to a GitHub repository, I managed to get it working only for the master branch.

I'm trying to get the branch being saved in order to push to the same branch remotely, I'm currently doing:

BRANCH=$(git --git-dir=. --work-tree=. branch --show-current)

this always returns master regardless of which branch was modified

I've also tried:

git log -1 HEAD

but only shows master commits

Is there a way to get the branch being change from a bash?

Thanks in advance

1

There are 1 best solutions below

0
On

After research you can get latest changed branch with

git branch --sort=-committerdate --format='%(refname:short)' | head -n 1