I am trying to use the git rev-list
command in a repo that I have setup a sparse checkout in.
Repo was set up as follows:
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
Now I would like to check for any changes in the 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>...]'
Any idea why I am getting the above error?
This is the bash script that is failing for me. The idea was to check for any changes to the remote repos and then pull them down. The reason I go through the trouble of checking for commits is because another function in the script runs an installation depending on what is updated.
# 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