
我正在編寫一個腳本,在其中一步中,我試圖獲取我的 git 分支之一的最新提交哈希值。
所以我的程式碼如下所示:
cd $sourceDirectory
COMMIT_HASH=$(git rev-parse $BRANCH_NAME)
echo "Commit hash is: $COMMIT_HASH"
但在 CI/CT 管道中執行腳本期間,我收到以下錯誤:
fatal: ambiguous argument '<branch-name>': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'