6

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
zedfoxus
  • 35,121
  • 5
  • 64
  • 63

1 Answers1

11

Instead of git log -n1, you could instead use:

COMMIT_ID=$(git rev-parse --verify HEAD)
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250