获取Git Commit ID作为版本管控

发布的App想要使用git commit ID作为版本管控,不想手动复制粘贴的话,可以通过git cmd来直接获取。

可以将其嵌入到工程内部中获取。

cd ~/xx/xx(cd到你的git 项目工程)

git status 

On branch MainBranch

Your branch is up to date with 'origin/testBranch'.

nothing to commit, working tree clean

git symbolic-ref --short -q HEAD (获取当前所在分支)

testBranch

git rev-parse --short HEAD(获取Short Commit ID)

cc3bc1b

git rev-parse HEAD(获取完整Commit ID)

cc3bc1bc9f8bf0c47911b563b6c8c0e37f2dde4d
Knowledge, like candlelight, can illuminate a person and countless people.
原文地址:https://www.cnblogs.com/xiaoqiangink/p/14596711.html