Not able to detect branch from Git post-receive hook

前端 未结 5 1509
面向向阳花
面向向阳花 2021-01-31 11:37

I\'ve got a post receive hook setup on the remote repo that tries to determine the branch name of the incoming push as follows:

$branch = `git rev-parse --abbrev         


        
5条回答
  •  醉梦人生
    2021-01-31 12:24

    You could also do something like this using bash variable substitution:

    read oldrev newrev ref
    
    branchname=${ref#refs/heads/}
    
    git checkout ${branchname}
    

提交回复
热议问题