Git-SVN 合并失去了主干的链接

发布于 2025-01-04 06:46:19 字数 1292 浏览 0 评论 0原文

编辑:我看到这个问题之前已经被问过! git-svn:重置 master 的跟踪 拥有正确权限的人可能可以关闭这是一个副本。

我正在使用 git-svn。我最近完成了 git 中的一个分支的工作,该分支正在跟踪 SVN 中的分支。在分支工作时,我使用了以下两个命令

$ git svn rebase
$ big svn dcommit

,一切正常。 git 中的“master”正在跟踪 svn/trunk,git 中的“myBranch”正在跟踪 svn/branches/myBranch。但是当我在 git 本地合并所有内容之后,

$ git checkout master
$ git merge myBranch

我去推送...并假设 master 会推送到 svn/trunk。但事实并非如此。相反,“master”现在也推送到 svn/branches/myBranch。不知何故,当我将“myBranch”合并到“master”时,“master”的跟踪发生了变化。

我可能做错了 - 但我试图明确地“推送”到主干......

$ git svn dcommit remotes/trunk master

但是该语法失败了,现在我的

$ Committing to http://<repo>/trunk ...
dcommitted on a detached HEAD because you gave a revision argument.
The rewritten commit is: b461234...

SVN 主干仍然没有更新。

如何在 git 中合并然后将其推送到 SVN?我遵循此处的指南,这意味着我可以与正常的 git 语法合并。它只是没有跟进并解释为什么我的“master”没有跟踪我合并的分支。

我也有 git-tower 我与命令行并行使用,在我按上述方式手动合并后,塔现在“显示”下拉列表中的所有远程分支以“推送”或dcommit,但我可以' t 更改选择svn/myBranch ...这可能意味着我不能?

EDIT: I see that this question has been asked before! git-svn: reset tracking for master Someone with the right permissions can probably close this as a duplicate.

I'm using git-svn. I recently finished working on a branch in git that was tracking a branch in SVN. While working in the branch, I was using the following two commands

$ git svn rebase
$ big svn dcommit

and all was well. "master" in git was tracking svn/trunk and "myBranch" in git was tracking svn/branches/myBranch. But after I merged everything locally in git

$ git checkout master
$ git merge myBranch

I went to push ... and assumed that master would push to svn/trunk. But it didn't. Instead, "master" now ALSO pushes to svn/branches/myBranch. Somehow, when I merged "myBranch" into "master", "master's" tracking got altered.

I am probably doing this wrong - but I tried to explicitly "push" to trunk ...

$ git svn dcommit remotes/trunk master

But that syntax failed and now I've got

$ Committing to http://<repo>/trunk ...
dcommitted on a detached HEAD because you gave a revision argument.
The rewritten commit is: b461234...

with SVN trunk still not updated.

How do I merge in git and then push that to SVN? I was following the guide here which implies that I can merge with normal git syntax. It just doesn't follow up and explain why my "master" is not tracking the branch I merge in.

I also have git-tower which I use in parallel with the command line and after I manually merged as above, tower now "shows" all the remote branches in the drop down to "push" or dcommit to, but I can't change the selection from svn/myBranch ... which possibly implies that I can't?

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

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

发布评论

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

评论(2

看轻我的陪伴 2025-01-11 06:46:19

如果 master 正在跟踪您的 svn 遥控器,您只需执行以下操作:

git svn dcommit

当您在 master 上时。使用 --dry-run 来确定您的提交的去向!如果它损坏了,您可以编辑 .git/config 并修复您的 svn-remote 条目:

[svn-remote "svn"]
     url = svn+ssh://some.machine.net/svn/path/to/tree
     fetch = trunk:refs/remotes/trunk

或者任何需要的内容。

If master is tracking your svn remote, you can just do:

git svn dcommit

While you're on master. Use --dry-run to see where your commit is headed to be sure! If it's broken, you can edit .git/config and fix up your svn-remote entry:

[svn-remote "svn"]
     url = svn+ssh://some.machine.net/svn/path/to/tree
     fetch = trunk:refs/remotes/trunk

Or whatever it needs to be.

时常饿 2025-01-11 06:46:19

不,您不能将 git 合并提交到 Subversion。

从您提供的链接中阅读有关 git svn 的分支问题的段落:

当您熟悉 Git 工作流程后,您可能会创建主题分支,对它们进行处理,然后将它们合并到其中。如果您通过 git svn 推送到 Subversion 服务器,您可能需要每次将您的工作重新定位到单个分支,而不是将分支合并在一起。更喜欢变基的原因是 Subversion 具有线性历史,并且不像 Git 那样处理合并,因此 git svn 在将快照转换为 Subversion 提交时仅遵循第一个父级。

在具有合并历史记录的分支上运行 dcommit 效果很好,只是当您查看 Git 项目历史记录时,它没有重写您在实验分支上所做的任何提交 - 相反,所有这些更改都显示在 SVN 中单个合并提交的版本。

当其他人克隆该工作时,他们看到的只是合并提交,所有工作都被压缩到其中;他们看不到有关它来自何处或何时提交的提交数据。

No, you can't commit git merges to Subversion.

Read this paragraph about branching issues with git svn from the link you gave:

When you’ve become comfortable with a Git workflow, you’ll likely create topic branches, do work on them, and then merge them in. If you’re pushing to a Subversion server via git svn, you may want to rebase your work onto a single branch each time instead of merging branches together. The reason to prefer rebasing is that Subversion has a linear history and doesn’t deal with merges like Git does, so git svn follows only the first parent when converting the snapshots into Subversion commits.

Running dcommit on a branch with merged history works fine, except that when you look at your Git project history, it hasn’t rewritten either of the commits you made on the experiment branch — instead, all those changes appear in the SVN version of the single merge commit.

When someone else clones that work, all they see is the merge commit with all the work squashed into it; they don’t see the commit data about where it came from or when it was committed.

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