I'm using the git post-checkout hook in my repo to the current branch into a variable, I then want to use it else where like PHP etc.
Below is my post-checkout script:
#!/bin/bash
echo $GITBRANCH
GITBRANCH=`git symbolic-ref HEAD | cut -d/ -f3-`
echo $GITBRANCH
export $GITBRANCH
However it doesn't update. For example:
>git checkout master
Switched to branch 'master'
develop
master
>echo $GITBRANCH
develop
Running the GITBRANCH=git symbolic-ref HEAD | cut -d/ -f3- command on it's own will then produce the current branch name.
Why doesn't the hook update the $GITBRANCH variable globally?
exportallows a variable to be used by its child processes, not its parent process.