简体   繁体   English

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

[英]What does “fatal: You are on a branch yet to be born” mean in this context

I was migrating a svn repo to git.我正在将 svn 存储库迁移到 git。 I created a clean temp dir, used git svn init to get stuff in there and then added the remote and pushed it.我创建了一个干净的临时目录,使用 git svn init 将内容放入其中,然后添加遥控器并推送它。 Now on the other actual source dir (which I had cloned from the empty repo before committing stuff from svn) I did a fetch.现在在另一个实际的源目录(在从 svn 提交内容之前,我从空仓库中克隆了它)我做了一个提取。 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免责声明:我是 git 新手

I believe it was because your fetch, which only fetches remote refs and commits, didn't give you a local master branch to checkout.我相信这是因为您的 fetch 仅获取远程 refs 和提交,并没有为您提供本地master分支来结帐。 Since you were in an empty repo, you were never on a branch, so your git checkout had no master branch to go to.由于您在一个空仓库中,因此您从未在分支上,因此您的git checkout没有到 go 的分支。

You could directly checkout the remote master by explicitly naming it with git checkout origin/master but that will leave you in a detached head state.您可以通过使用git checkout origin/master明确命名远程主机来直接签出远程主机,但这将使您处于分离的头 state 中。

Once you did the pull, it fetched and merged, the pull created a local master to track the remote master.一旦你完成了拉取,它获取合并,拉取创建了一个本地主节点来跟踪远程主节点。

I was having the same error trying to migrate svn to git.我在尝试将 svn 迁移到 git 时遇到了同样的错误。 Here was my fix.这是我的修复。

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:将分离的头部转换为主分支:

git checkout -b master

At this point your git repo will function normally.此时,您的 git 存储库将正常运行 function。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM