【发布时间】:2020-07-17 12:44:49
【问题描述】:
我正在尝试在我已设置稀疏结帐的存储库中使用 git rev-list 命令。
回购设置如下:
mkdir -p /opt/apcu
git -C /opt/apcu/ init
git -C /opt/apcu/ remote add -f origin git@github.com:krakjoe/apcu.git
git -C /opt/apcu/ config core.sparseCheckout true
echo "apc.php" >> /opt/apcu/.git/info/sparse-checkout
git -C /opt/apcu/ config branch.master.remote origin
git -C /opt/apcu/ config branch.master.merge refs/heads/master
git -C /opt/apcu/ pull origin
现在我想检查 repo 中的任何更改:
$ git rev-list HEAD...origin
fatal: ambiguous argument 'HEAD...origin': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
知道为什么会出现上述错误吗?
这是我失败的 bash 脚本。这个想法是检查远程存储库的任何更改,然后将它们拉下来。我在检查提交时遇到麻烦的原因是脚本中的另一个函数根据更新的内容运行安装。
# Do not fetch or pull "master" this is not always the default branch you have checked out.
# Omitting the branch to fetch or pull will pull the default.
for i in "${repo_array[@]}"; do
git -C "$i" fetch origin &>/dev/null
# Get rid of errors because git reports differences in repo as errors.
commits=$(git -C "$i" rev-list HEAD...origin --count 2>/dev/null)
if (( commits != 0 )); then
git -C "$i" pull origin &>/dev/null
# Run the installer function to install new versions
installer
fi
done
【问题讨论】: