How to get remote branch name in git pre-push hook

git, git-branch, githooks

Solution

Remote branch name can be accessed using:

while read local_ref local_sha remote_ref remote_sha 
do 
    echo $local_ref
    echo $local_sha 
    echo $remote_ref
    echo $remote_sha
done 

Problem

The documentation says: Information about what is to be pushed is provided on the hook's standard input with lines of the form: < local ref> SP < local sha1> SP < remote ref> SP < remote sha1> LF For instance, if the command +git push origin master:foreign+ were run the hook would receive a line like the following: refs/heads/master 67890 refs/heads/foreign 12345 how do I access those lines in the pr-hook script?

Original source

Related problems