我需要使用复杂的存储库配置。我有5个:
所以,我理解它的工作原理如下:
现在我在机器3上做了一些更改,我想将这些更改推送到机器4.以下是我需要遵循的说明:
我遇到第4步的问题。我收到以下错误:
fatal: 'machine3/test-branch' is not a commit and a branch 'test-branch' cannot be created from it
已添加
执行时
git rev-parse machine3/test-branch
在我的笔记本电脑(机器2)上,我得到了:
machine3/test-branch
fatal: ambiguous argument 'machine3/test-branch': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
答案 0 :(得分:4)
对于那些在此搜索fatal: 'origin/branch' is not a commit and a branch 'branch' cannot be created from it
的人来说,您可能还想先尝试git fetch
。
如果您在没有先进行git checkout -b local-branch-name origin/different-branch-name
的情况下运行fetch
,则会遇到该错误。
答案 1 :(得分:1)
我设法通过此设置解决了这个问题,只需使用此命令更新配置
git config -e --global
并添加此配置。
[remote "origin"]
url = https://git.example.com/example.git (you can omit this URL)
fetch = +refs/heads/*:refs/remotes/origin/*
然后您可以git fetch --all
答案 2 :(得分:1)
我们遇到了这个错误:
fatal: 'origin/newbranch' is not a commit and a branch 'newbranch' cannot be created from it
因为我们做了一个极简的克隆:
git clone --depth 1 --branch 'oldbranch' --single-branch 'git@github.com:user/repo.git'
对我们来说,最简单的修复是:
git remote set-branches --add 'origin' 'newbranch'
git fetch 'origin'
git checkout --track 'origin/newbranch'
假设远程名为“origin”,远程分支名为“newbranch”。
答案 3 :(得分:0)
问题是复杂/卷积,答案很简单。别名和机器3之间存在不匹配。已使用的远程别名不适用于machine3。机器3有另一个别名。
答案 4 :(得分:0)
如果您要从标记中检出分支(例如P
),则可以先尝试git checkout -b XXXX v0.1.1
。
答案 5 :(得分:0)
答案 6 :(得分:0)
对于这个问题:
fatal: 'machine3/test-branch' is not a commit and a branch 'test-branch' cannot be created from it
对我来说,我应该先检查 test-branch
,然后它工作正常并从 test-branch
创建一个新分支。
答案 7 :(得分:-1)
来自J.D. Mallen的解决方案涉及git fetch --all
从 VSCode 1.53(2021 年 1 月)开始,您将拥有(issue 110811 和 PR 111090):
<块引用>将 autofetch
更改为具有“current
”、“all
”和“off
”的字符串配置。
这允许用户从所有遥控器中获取,而不仅仅是他们的 origin
。
对于在 Fork 上工作的开发人员来说,这应该会使扩展程序更直观地工作。
因此,如果您将 VSCode 设置 git.autofetch
设置为“all
”,您甚至不必键入 git fetch --all
。