Git-Svn dcommit 导致分支分裂

发布于 2024-10-31 08:20:37 字数 1364 浏览 3 评论 0原文

我遇到了 git-svn dcommits 问题,导致 git 存储库无法跟踪哪些提交。

我尝试确保 git 中的 master 分支始终遵循 SVN 存储库中的 trunk。所以每当我工作时,我都会在一个主题分支上。这是我的场景:

在主题分支中工作一段时间

git checkout -b my-topic
git commit -m "blah blah blah"

然后我决定将我的分支合并回 master

git checkout master
git svn rebase #get any changes in svn
git rebase master my-topic
git merge my-topic --ff-only

直到这里,一切都进展顺利。我现在让 master 和 my-topic 都加快速度并指向同一个提交,整个历史看起来像这样:

A -- B -- C - master + my-topic

但是,当我这样做时,

git svn dcommit

我最终会得到一棵看起来像这样的树(B 和 C 是我最初的提交)针对主题):

  -- B -- C - my-topic
 /
A -- B -- C - master + remotes/trunk

似乎在 dcommit 过程中,git 将提交推送到 SVN,然后在 master 上重放它们。我认为问题在于他们获得了不同的提交者信息。我正在使用 tortoise plink 和 SSH 密钥登录 svn。

git 存储库中尚未推送到 SVN 的提交的提交者信息为:

Collin Hockey <[email protected]>

已推送到 svn 存储库的提交有这样的信息:

chockey <chockey@6206317d-b652-48a9-a948-4036602fc523>

有什么办法可以防止这些分支分裂吗?我可以通过再说一遍来解决这个问题

git rebase master my-topic

,但我觉得这应该是不必要的。这样做的主要问题是,一旦分支的更改被推送到 SVN,git 就不再认为该分支已在任何地方合并。删除不再需要的旧分支会让人感到困惑。

I'm having a problem with git-svn dcommits making the git repository lose track of which commits are which.

I try to make sure that the master branch in git always follows trunk in the SVN repository. So whenever I'm working, I'm on a topic branch. Here's my scenario:

Working in a topic branch for a while

git checkout -b my-topic
git commit -m "blah blah blah"

Then I decide I'd like to merge my branch back in to master

git checkout master
git svn rebase #get any changes in svn
git rebase master my-topic
git merge my-topic --ff-only

Up until here, everything has gone well. I now have both master and my-topic up to speed and pointing at the same commit, and the entire history looks like this:

A -- B -- C - master + my-topic

However, when I do

git svn dcommit

I end up with a tree that looks like this (B and C are commits I originally made to the topic):

  -- B -- C - my-topic
 /
A -- B -- C - master + remotes/trunk

It seems like during the dcommit process, git pushes the commits up to SVN, then replays them back on top of master. The problem I think is that they get different committer information. I'm logging into svn with tortoise plink and an SSH key.

Commits in the git repository that have not been pushed to SVN have committer info as:

Collin Hockey <[email protected]>

Commits that have been pushed to the svn repository have this though:

chockey <chockey@6206317d-b652-48a9-a948-4036602fc523>

Is there any way I can keep these branches from splitting? I can sort of fix it by saying

git rebase master my-topic

again, but I feel like that should be unnecessary. The main problem with this is that once a branch's changes are pushed to SVN, git no longer thinks that branch has been merged anywhere. It makes it confusing to delete old branches you no longer need.

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

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

发布评论

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

评论(2

几度春秋 2024-11-07 08:20:37

git svn dcommit 命令的工作原理如下:

  1. 查找来自 SVN 的最后一次提交;我们称之为 last-svn
  2. last-svn..HEAD 范围内的提交发送到 Subversion(顺便丢弃电子邮件)
  3. 重置 HEADlast-svn
  4. 从 SVN 更新并创建相应的提交

换句话说,您发送到 SVN 的提交将被销毁,并从 SVN 的更新中重新创建。这一定会发生,因为来自 SVN 的提交与使用 Git 创建的提交不同:

  • 它们的描述包含对 SVN 修订版的引用
  • 他们的作者电子邮件是根据 SVN 用户名计算出来的

这就是为什么你的分支 my-topic< /code> 与 master 不同。

您可以自定义 git svn dcommit 使用 --authors-file--authors-prog 从 SVN 用户名计算作者电子邮件的方式代码>选项。

The git svn dcommit command works as follows:

  1. Find the last commit coming from SVN; let's call it last-svn
  2. Send the commits in the range last-svn..HEAD to Subversion (discarding the e-mail by the way)
  3. Reset the HEAD to last-svn
  4. Update from SVN and create the corresponding commits

In other words, the commits you send to SVN are destroyed and recreated from the update from SVN. This must happen because the commits that come from SVN are different from the ones created with Git:

  • Their description contains a reference to the SVN revision
  • Their author e-mail is computed from the SVN username

That's why your branch my-topic diverges from master.

You can customize the way git svn dcommit computes the author e-mail from the SVN username with the --authors-file and --authors-prog options.

旧城空念 2024-11-07 08:20:37

你是对的,git 再次从 svn 重放提交。 git 中的分支只是指向提交的指针(或者有 ids/hashes)。来自 svn 的提交将具有不同的哈希值,并且只有当前签出的分支由 git svn dcommit 更新,因此您的主题分支仍然指向旧的提交

you are right, that git replays the commits again from svn. branches in git are only pointers to commits (or there ids/hashes). the commits from svn will have different hashes, and only the currently checked out branch is updated by git svn dcommit, so your topic branch still points to the old commits

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