在 Github 操作中访问回购分支

Access repo branches in Github Action

我想在 Github 操作中执行分支比较。但是 git branch returns 一个类似 ls 的结果,而不是一个文件列表!

run: echo $(git branch)

shell: /bin/bash -e {0}

LICENSE README.md index.html node_modules package-lock.json package.json src yarn.lock (HEAD detached at pull/29/merge)

这是为什么?坏了吗?

如何在分支上执行 git 命令?

git branch returns 当前分支用星号标记的列表 *。然后 echo(实际上是 shell)扩展星号。

处理 git branch 的输出并删除 * 或使用 git for-each-ref refs/heads/.

更新git clone --depth implies --single-branch。获取其他分支:

git remote set-branches origin '*'
git fetch

git shallow clone (clone --depth) misses remote branches