Answers:
uploadpack.allowReachableSHA1InWant
由于Git 2.5.0可以在服务器上启用此配置变量,因此GitHub功能请求和GitHub提交启用了此功能。
从5.5+版本开始,Bitbucket Server启用了它。
用法:
# Make remote with 4 commits, and local with just one.
mkdir server
cd server
git init
touch 1
git add 1
git commit -m 1
git clone ./ ../local
for i in {2..4}; do
touch "$i"
git add "$i"
git commit -m "$i"
done
# Before last commit.
SHA3="$(git log --format='%H' --skip=1 -n1)"
# Last commit.
SHA4="$(git log --format='%H' -n1)"
# Failing control without feature.
cd ../local
# Does not give an error, but does not fetch either.
git fetch origin "$SHA3"
# Error.
git checkout "$SHA3"
# Enable the feature.
cd ../server
git config uploadpack.allowReachableSHA1InWant true
# Now it works.
cd ../local
git fetch origin "$SHA3"
git checkout "$SHA3"
# Error.
git checkout "$SHA4"
git pull server:repo
vs常规git pull
)需要指定远程服务器