神秘的 git 行为

发布于 2024-10-31 22:31:20 字数 1211 浏览 2 评论 0原文

我已经解决了这个问题。但我仍然不知道为什么我所做的事情有效。

我们有一个 svn 存储库来存放我们工作中的代码。我有一个本地 git-svn 存储库,因为我 <3 Git。 :) 我们使用 Windows,所以我使用 Cygwin。我认为 Cygwin 的最新版本是 Git 1.7.0.4。周五,我毫无问题地提交了代码,然后回家了。周一早上我回来,并尝试“git svn rebase”,因为有人在周末提交了代码(成绩优异)。

开始很正常,然后突然发现找不到行李箱了。不幸的是,我丢失了确切的错误消息,但它大喊着找不到 /refs/remotes/trunk ……我非常害怕。不过幸运的是,我没有未提交的代码。没什么可失去的。然而,每次我尝试“git svn rebase”之后,它都会永远挂起,然后我会收到以下错误:

无法从工作树历史记录中确定上游 SVN 信息

我研究了一整天。我尝试从 https://xxx.xxx.xxx/xxx/xxx 到 https://xxx.xxx.xxx/xxx/xxx/ 尽管这看起来很荒谬。然后我执行了“git svn fetch”...它重新获取了整个主干(所有 1682 次提交)。但 rebase 仍然不起作用。所以我放弃了这一天,并决定第二天我将创建一个新的存储库并重新开始(这将需要一整天)。今天早上,在我毫不掩饰地删除我的存储库之前,我去这里问了这个问题。我遇到了这个:

git-svn rebase gone horribly error

这不是正是我的问题,但我决定尝试“git reset --hard trunk”,因为这就是我想要的。它奏效了。现在一切都很好。

然而。

它首先为什么要这样做?据我所知,我没有改变任何东西,因为我周末没有上班。什么样的事情会导致这个错误?我想我心不在焉地做了一些可怕的事情,但我需要知道是什么,这样我就不会再这样做了。 :)

提前致谢。

I have since fixed this problem. But I still don't know why what I did worked.

We have an svn repository for our code at work. I have a local git-svn repository because I <3 Git. :) We use Windows, so I use Cygwin. I think the latest version in Cygwin is Git 1.7.0.4. On Friday, I dcommitted my code without a problem, went home. Monday morning I came back, and tried to 'git svn rebase' because someone had committed code over the weekend (overachievers).

It began normally, and then suddenly decided it couldn't find the trunk. Unfortunately, I lost the exact error message, but it was yelling about not being about to find /refs/remotes/trunk ...and I was very scared. Luckily, though, I had no uncommitted code. Nothing to lose. Nevertheless, every time I tried to 'git svn rebase' after that, it would hang forEVER, and then I would get the following error:

Unable to determine upstream SVN information from working tree history

I researched it for a whole day. I tried changing the svn-remote url from https://xxx.xxx.xxx/xxx/xxx to https://xxx.xxx.xxx/xxx/xxx/ as ridiculous as that seems. I then did a 'git svn fetch' ... and it re-fetched the whole trunk (all 1682 commits). But the rebase still wouldn't work. So I gave up for the day, and decided that the next day I would just create a new repository and start over (which would take a whole day). This morning, I went to ask the question on here before I went unabashedly deleting my repository. I came across this:

git-svn rebase gone horribly wrong

which wasn't exactly my problem, but I decided to try 'git reset --hard trunk' because that's what I wanted. And it worked. Everything is fine now.

However.

Why did it do that in the first place? I didn't change anything as far as I know, as I was not at work over the weekend. What kind of things would have caused that error? I assume I absent-mindedly did something awful, but I need to know what so I don't do it again. :)

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

野稚 2024-11-07 22:31:20

这个错误:

Unable to determine upstream SVN information from working tree history

听起来你当前的 git 历史记录根本不是基于 svn 历史记录,因此 rebase 找不到共同的祖先。

通过更改 URL,我认为所有提交的提交消息都略有不同,因此 sha1 哈希值也不同,因此您的旧祖先与新祖先不匹配,导致 rebase 失败。

至于为什么 trunk 消失/失败,如果没有错误消息,很难理解发生了什么。

This error:

Unable to determine upstream SVN information from working tree history

Sounds like your current git history was not based on the svn history at all, and thus rebase couldn't find a common ancestor.

By changing the URL, I think all the commits have SLIGHTLY different commit messages, and therefore different sha1 hashes, and therefore your old ancestors do not match the new ones, causing rebase to fail.

As to why trunk disappeared/failed, it would be pretty hard to understand what happened without the error message.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文