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,以备它用。