浅克隆无法获取新的提交/分支?

2023-12-24

我有这个:

git clone --depth=1 <repo> app
cd app
git fetch origin
git checkout a119b1076dd45a88a3609c4f7893ef3d82f9a4ee

但它说:

fatal: reference is not a tree: a119b1076dd45a88a3609c4f7893ef3d82f9a4ee

如果我使用分支的名称:

 git checkout me/work

I get:

error: pathspec 'me/work' did not match any file(s) known to git.

是因为我做了浅克隆吗?对我来说没有多大意义。提交位于远程,至少具有该名称的分支/提交位于远程。

Update:

所以我添加了一个--all to 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

所以分支不在that列出来,如果这有助于有人帮助我。


作为文档--depth says,

Implies --single-branch unless --no-single-branch给出

所以如果你想要

获取所有分支尖端附近的历史记录

give --no-single-branch在你的克隆上,或者为了一次性更正,自己获取,

git fetch --depth=1 origin +refs/heads/*:refs/remotes/origin/*

或追溯关闭单分支设置

git config remote.origin.fetch +refs/heads/*:refs/remotes/origin/*

进而git fetch.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

浅克隆无法获取新的提交/分支? 的相关文章

随机推荐