git 在这种情况下,“致命:你在一个尚未出生的分支上”是什么意思

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7083272/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 11:36:11  来源:igfitidea点击:

What does "fatal: You are on a branch yet to be born" mean in this context

gitgit-checkout

提问by Osada Lakmal

I was migrating a svn repo to git. I created a clean temp dir, used git svn init to get stuff in there and then added the remote and pushed it. Now on the other actual source dir (which I had cloned from the empty repo before committing stuff from svn) I did a fetch. And then I did a checkout and got above message. After a while I figured that I could get the source with a pull and did that. My question is what did that error message mean in that context ? How did I get that particular error message ? Disclaimer : I am a git newbie

我正在将 svn repo 迁移到 git。我创建了一个干净的临时目录,使用 git svn init 在那里获取东西,然后添加遥控器并推送它。现在在另一个实际的源目录上(我在从 svn 提交东西之前从空仓库克隆了它)我做了一个提取。然后我进行了结帐并收到了上述消息。过了一会儿,我想我可以通过拉动获得源并做到了。我的问题是该错误消息在这种情况下意味着什么?我是如何得到那个特定的错误信息的?免责声明:我是一个 git 新手

采纳答案by Andy

I believe it was because your fetch, which only fetches remote refs and commits, didn't give you a local masterbranch to checkout. Since you were in an empty repo, you were never on a branch, so your git checkouthad no masterbranch to go to.

我相信这是因为你的 fetch 只获取远程引用和提交,没有给你一个本地分支来结账。因为你在一个空的仓库中,你从来没有在一个分支上,所以你git checkout没有分支可以去。

You could directly checkout the remote master by explicitly naming it with git checkout origin/masterbut that will leave you in a detached head state.

您可以通过显式命名为 with 来直接签出远程主机,git checkout origin/master但这将使您处于分离的状态。

Once you did the pull, it fetched andmerged, the pull created a local masterto track the remote master.

一旦你完成了拉取,它就获取合并了,拉取创建了一个本地主节点来跟踪远程主节点。

回答by Luke Dupin

I was having the same error trying to migrate svn to git. Here was my fix.

我在尝试将 svn 迁移到 git 时遇到了同样的错误。这是我的修复。

Confirm you've initialized the git repo:

确认您已初始化 git 存储库:

git init

Confirm you actually had a valid migration from svn:

确认您确实从 svn 进行了有效的迁移:

git branch --remote

#You should see this output:
#git-svn

Create a detached head:

创建一个分离的头部:

git checkout git-svn

Convert the detached head into the master branch:

将分离的 head 转换为 master 分支:

git checkout -b master

At this point your git repo will function normally.

此时您的 git repo 将正常运行。