简体   繁体   中英

How to print the latest commit ID from the git repo using shell script

I have the following shell script in linux environment, in which arr has the list of git repo paths and when I tried running this script, I am getting into that path through the line 3, but I am not able to get the latest commit ID and save in the variable, what I am missing in this code and how to get that commit ID in that variable "commit_ID".

for i in "${arr[@]}"
do
 cd $i
 echo $i
 commit_ID = git log -1
 echo $commit_ID
done

代替git log -n1 ,您可以改用

COMMIT_ID=$(git rev-parse --verify HEAD)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM