浅克隆无法获取新的提交/分支? [英] Shallow clone cannot fetch new commits/branches?
问题描述
我有这个:
git clone --depth=1 <repo> app
cd app
git fetch origin
git checkout a119b1076dd45a88a3609c4f7893ef3d82f9a4ee
但是它说:
fatal: reference is not a tree: a119b1076dd45a88a3609c4f7893ef3d82f9a4ee
如果我使用分支的名称:
if I use the name of the branch:
git checkout me/work
我得到:
error: pathspec 'me/work' did not match any file(s) known to git.
是因为我做了一个浅表克隆吗?对我来说没有多大意义.提交位于远程上,至少具有该名称的分支/提交位于远程上.
is it because I did a shallow clone? don't make much sense to me. The commit is on the remote, at the very least the branch/commit with that name is on the remote.
更新:
所以我在 git fetch --all
上添加了-all
,然后运行 git branch -vv --all
:
So I added an --all
to git fetch --all
and then ran git branch -vv --all
and I see:
* master 4761f83 [origin/master] timeline event update date should not be the review date. Every time it is inserted or updated the update date should be the current utc date
remotes/origin/HEAD -> origin/master
remotes/origin/master 4761f83 timeline event update date should not be the review date. Every time it is inserted or updated the update date should be the current utc date
因此该分支不在那个列表中,如果这可以帮助某人帮助我.
so the branch is not in that list, if that helps someone help me.
推荐答案
正如-depth
的文档所述,
除非给出
-no-singlebranch
,否则使用-single-branch
所以如果你想
获取所有分支机构提示附近的历史记录
to fetch the histories near the tips of all branches
在克隆上提供-无单分支
,或者一次校正即可自己进行获取,
give --no-single-branch
on your clone, or for one-off correction do the fetch yourself,
git fetch --depth=1 origin +refs/heads/*:refs/remotes/origin/*
或追溯关闭单分支设置
git config remote.origin.fetch +refs/heads/*:refs/remotes/origin/*
,然后 git fetch
.
这篇关于浅克隆无法获取新的提交/分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!