linux bash脚本 获取git最近一次提交的commit id
一、获取完整commit id( 如:239e0750aec6e249e49a43bb279dac87ffa01a6e)
git rev-parse HEAD
git rev-parse --short HEAD
三、测试脚本代码
#!/bin/bash
current_git_branch_latest_id=`git rev-parse HEAD`
current_git_branch_latest_short_id=`git rev-parse --short HEAD`
echo current git branch latest commit id=$current_git_branch_latest_id
echo current git branch latest commit short id=$current_git_branch_latest_short_id四、本测试结果,成功获取commit id,以备它用。

版权声明:本文为qq_37858386原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。