浅克隆无法获取新的 commits/branches?
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
如果我使用b运行ch的名称:
git checkout me/work
我得到:
error: pathspec 'me/work' did not match any file(s) known to git.
是因为我做了浅克隆吗?对我来说没有多大意义。提交在遥控器上,至少具有该名称的 branch/commit 在遥控器上。
更新:
所以我添加了一个 --all
到 git fetch --all
然后 运行 git branch -vv --all
然后我看到:
* 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
所以 b运行ch 不在 that 列表中,如果这有助于有人帮助我。
当您进行浅克隆时,您可能需要指定要获取的分支:
git clone --depth=1 --branch=me/work <repo> app
我认为如果你做一个浅克隆,这种方法是可行的
git fetch origin me/work
git checkout -b temp FETCH_HEAD
正如 --depth
的文档所说,
Implies --single-branch
unless --no-single-branch
is given
所以如果你想
to fetch the histories near the tips of all branches
在您的克隆上提供 --no-single-branch
,或者为了 one-off 更正,您自己进行获取,
git fetch --depth=1 origin +refs/heads/*:refs/remotes/origin/*
或追溯关闭 single-branch 设置
git config remote.origin.fetch +refs/heads/*:refs/remotes/origin/*
然后是git fetch
.
A shallow clone is also, by default, a single-branch clone:
--depth <depth>
Create a shallow clone with a history truncated to the specified number of commits. Implies --single-branch
unless ...
A single-branch 克隆正如其名:仅从上游复制一个分支的克隆。 (底层机制是通过默认的 fetch
refspecs,因此您可以通过提供 refspecs 暂时覆盖一次提取。)
如果您希望浅克隆复制多个分支,则必须将其转换为非single-branch 克隆,或者从非single-branch 克隆开始。作为一个开始,继续阅读引用句子的其余部分。要将现有的 single-branch 克隆更改为两个、三个或 all-branch 个克隆,请参阅 How do I "undo" a --single-branch clone?
我有这个:
git clone --depth=1 <repo> app
cd app
git fetch origin
git checkout a119b1076dd45a88a3609c4f7893ef3d82f9a4ee
但上面写着:
fatal: reference is not a tree: a119b1076dd45a88a3609c4f7893ef3d82f9a4ee
如果我使用b运行ch的名称:
git checkout me/work
我得到:
error: pathspec 'me/work' did not match any file(s) known to git.
是因为我做了浅克隆吗?对我来说没有多大意义。提交在遥控器上,至少具有该名称的 branch/commit 在遥控器上。
更新:
所以我添加了一个 --all
到 git fetch --all
然后 运行 git branch -vv --all
然后我看到:
* 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
所以 b运行ch 不在 that 列表中,如果这有助于有人帮助我。
当您进行浅克隆时,您可能需要指定要获取的分支:
git clone --depth=1 --branch=me/work <repo> app
我认为如果你做一个浅克隆,这种方法是可行的
git fetch origin me/work
git checkout -b temp FETCH_HEAD
正如 --depth
的文档所说,
Implies
--single-branch
unless--no-single-branch
is given
所以如果你想
to fetch the histories near the tips of all branches
在您的克隆上提供 --no-single-branch
,或者为了 one-off 更正,您自己进行获取,
git fetch --depth=1 origin +refs/heads/*:refs/remotes/origin/*
或追溯关闭 single-branch 设置
git config remote.origin.fetch +refs/heads/*:refs/remotes/origin/*
然后是git fetch
.
A shallow clone is also, by default, a single-branch clone:
--depth <depth>
Create a shallow clone with a history truncated to the specified number of commits. Implies--single-branch
unless ...
A single-branch 克隆正如其名:仅从上游复制一个分支的克隆。 (底层机制是通过默认的 fetch
refspecs,因此您可以通过提供 refspecs 暂时覆盖一次提取。)
如果您希望浅克隆复制多个分支,则必须将其转换为非single-branch 克隆,或者从非single-branch 克隆开始。作为一个开始,继续阅读引用句子的其余部分。要将现有的 single-branch 克隆更改为两个、三个或 all-branch 个克隆,请参阅 How do I "undo" a --single-branch clone?