git-svn-id在某些提交中丢失 [英] git-svn-id is missing from some commits

查看:104
本文介绍了git-svn-id在某些提交中丢失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 git-svn 检出了一个旧的SVN存储库,以便使用它并推送到Heroku。我做了一个非常标准的 git push heroku master , git svn rebase git svn dcommit



然而,最近我一直在做一些git工作,并没有做一个 git svn rebase 。现在,当我尝试进行重新分配时,由于合并冲突而失败,尽管我是唯一一个承诺回购并且只能在主人身上工作的人。



证明它可能会成为问题的工作副本我做了一个新的 git svn clone 然后一个 git remote add heroku git pull heroku master 。 pull做了快进合并,没有问题,但是 git svn rebase 仍然失败。



我做了一个简单的 git log ,我发现我有一些旧的提交缺少 git-svn-id s:

 提交def8bab861314c67d4e8227e03775d19045d21d1 
作者:peterr
日期:星期五9月21日16:17:33 2012 +0000

PHP Cedar支持。

git-svn-id:http://vcp.unfuddle.com/svn/vcp_bbsit@24 b6b24ac3-8b7a-4c11-a811-49c5d0334e85

commit f51bd78fb07dde6ec1dc4e0ba51a48f2b6bd1bd6
作者:pr1001
日期:8月20日星期一19:39:42 2012 +0200

正确指定端口

commit 153bb2929080898dcab46142120def0f4964dfab

...

commit 5a416fa3af9f64aa353d5171bedfaa563115ff62
作者:pr1001
日期:8月20日星期一17:22:58 2012 +0200

PHP Cedar支持。

提交e0b35588d03082a3a4ab49a7b590f206346046c0
作者:j
日期:星期五8月3日08:13:33 2012 +0000

更改电子邮件

git-svn-id:http://vcp.unfuddle.com/svn/vcp_bbsit@23 b6b24ac3-8b7a-4c11-a811-49c5d0334e85

一个SO回答我收集到,我可能能够重写提交消息来添加缺少的信息,但我不知道这是否会更糟糕。



看看这些消息,它看起来像我有一些重复的提交,例如'PHP雪松支持'之一。我真的很困惑,为什么我有这些重复,虽然我怀疑他们可能会被转发到失败的 git push heroku master 我有一天我被告知存储库不同步。 git pull heroku master 似乎绝对没有带来任何变化并解决了问题,但也许它带来了重复的提交。



所以,考虑到这一切,我的问题很简单,我该如何继续?我在Heroku上有一个可用的应用程序,并且在SVN仓库中有一个较旧的工作代码库,但是我没有看到任何简单的方法来清楚地获得SVN中较新的提交。我应该挑樱桃吗?然后,我需要加载Heroku应用程序,以避免重复出现? 解决方案

不容易猜到你陷入了这种情况,但我认为这是因为当推送到SVN时,git-svn用git-svn-id签名替换(使用rebase或reset)提交,所以每个提交有2个范例:local - 没有git-svn-id签名---远程签名。



恢复:


  1. 创建一个临时分支以保持当前状态(某种
    备份): git co -b backup

  2. 请确保refs / remotes / git-svn指向与您的Subversion存储库对应的git-svn-id的最新提交,并且没有没有git-svn-id的提交由 git log refs / remotes / git-svn

如果不是这样,您可以使用以下诡计修复refs / remotes / git-svn:
更新refs / remotes / git-svn到point到一切正常的最新提交(在你的情况下它对应于r23):

  $ git update-ref refs / remotes / git-svn e0b35588d03082a3a4ab49a7b590f206346046c0 

将.git / svn / metadata修订版设置为指向该修订版:

  [svn-remotesvn] 
reposRoot = ...
uuid =< UUID>
branches-maxRev = 23
tags -maxRev = 23

移除(或git-svn / .rev_map.UUID
现在运行

  $ git svn fetch 

您的refs / remotes / git-svn参考现已恢复到最新版本有效的SVN版本。



3。在不合并的情况下从Git存储库中获取所有更改

  $ git fetch heroku master 

现在您的所有更改都在refs / remotes / heroku / master。

确保你没有本地的变化(我建议你现在在掌握)。将refs / heads / master重置为refs / remotes / git-svn。其中一种方法:

  $ git update-ref refs / heads / master refs / remotes / git-svn 
$ git reset --hard HEAD

5。看看refs / remotes / heroku / master和refs / remotes / git-svn。 Git存储库中是否存在refs / remotes / git-svn中不存在的更改?如果是的话,樱桃采摘他们一个接一个。也可以看看你的备份分支(仅在没有git-svn-id的情况下提交),如果它们不在SVN中,也可以选择它们。



6 。现在,您在master中还有一些不在SVN中的更改。运行

  $ git svn dcommit 

推送他们到SVN。



7。现在您的SVN相关分支已经完全修复并且具有所有更改。如果我理解正确,您需要Git存储库中的相同内容。更好地用当前主内容替换refs / remotes / heroku / master:

  $ git push heroku master --force 

现在您的Git存储库与SVN存储库具有相同的内容。



<为避免将来出现这些问题,请确保您从不在没有git-svn-id的情况下将提交提交给Git(即,当您运行git push时,您的主服务器包含git-svn-只有id标志 - 如果没有 - 运行git svn dcommit将它们先推送到SVN)。

I have an old SVN repository that I checked out using git-svn in order to work on it and push to Heroku. I was doing a pretty standard git push heroku master, git svn rebase, git svn dcommit dance and things were fine.

However, recently I've been doing a fair bit of git work and hadn't done a git svn rebase in a while. Now when I try to do a rebase it fails because of merge conflicts, despite me being the only person committing to the repo and only working on master.

Figuring that it might be the working copy that's the problem I did a new git svn clone and then a git remote add heroku and git pull heroku master. The pull does a fast-forward merge with no problems, but git svn rebase still fails.

I did a simple git log and I see that I have some old commits missing git-svn-ids:

commit def8bab861314c67d4e8227e03775d19045d21d1
Author: peterr
Date:   Fri Sep 21 16:17:33 2012 +0000

    PHP Cedar support.

    git-svn-id: http://vcp.unfuddle.com/svn/vcp_bbsit@24 b6b24ac3-8b7a-4c11-a811-49c5d0334e85

commit f51bd78fb07dde6ec1dc4e0ba51a48f2b6bd1bd6
Author: pr1001
Date:   Mon Aug 20 19:39:42 2012 +0200

    Specify port correctly

commit 153bb2929080898dcab46142120def0f4964dfab

...

commit 5a416fa3af9f64aa353d5171bedfaa563115ff62
Author: pr1001
Date:   Mon Aug 20 17:22:58 2012 +0200

    PHP Cedar support.

commit e0b35588d03082a3a4ab49a7b590f206346046c0
Author: j
Date:   Fri Aug 3 08:13:33 2012 +0000

    change email

    git-svn-id: http://vcp.unfuddle.com/svn/vcp_bbsit@23 b6b24ac3-8b7a-4c11-a811-49c5d0334e85

From an SO answer I gather that I might be able to rewrite the commit messages to add the missing information, but I wonder whether that wouldn't be even worse.

Looking at the messages, it looks like I have some duplicate commits, such as the 'PHP Cedar support' one. I'm really perplexed why I have these duplicates, though I suspect that they may be relayed to the failed git push heroku master I had the other day in which I was told the repositories were out of sync. git pull heroku master seemed to bring in absolutely no changes and fixed the issue, but perhaps it brought in the duplicate commits.

So, given all this my question is simply, how might I proceed? I have a working app on Heroku and an older working code base in the SVN repo, but I don't see any easy way how to cleanly get the newer commits into SVN. Should I cherry-pick them? Would I then need to nuke the Heroku app in order to not have the duplicates come back?

解决方案

It's not easy to guess how you got into this situation, but I think this is because when pushing to SVN git-svn replaces (using rebase or reset) commits with git-svn-id signature so there're 2 exemplars of each commits: "local" -- without "git-svn-id" signature --- and remote with the signature.

To recover:

  1. Create a temp branch to keep your current state (some kind of backup): git co -b backup
  2. Make sure that refs/remotes/git-svn points to the latest commit with git-svn-id corresponding to your subversion repository and there's no commits without git-svn-id are shown by git log refs/remotes/git-svn

If this is not true, you may use the following trick to repair refs/remotes/git-svn: update refs/remotes/git-svn to point to the latest commit where everything was ok (in your situation it corresponds to r23):

$ git update-ref refs/remotes/git-svn e0b35588d03082a3a4ab49a7b590f206346046c0

Set .git/svn/metadata revisions to point to that revision:

[svn-remote "svn"]
        reposRoot = ...
        uuid = <UUID>
        branches-maxRev = 23
        tags-maxRev = 23

Remove (or better move away) file .git/svn/refs/remotes/git-svn/.rev_map.UUID Now run

$ git svn fetch

Your refs/remotes/git-svn reference is now restored to the latest valid SVN revision.

3 . Get all changes from the Git repository without merging

$ git fetch heroku master

Now all your changes are in refs/remotes/heroku/master.

4 . Make sure you have no local changes (I suggest you're on master now). Reset refs/heads/master to refs/remotes/git-svn. One of the ways to do that:

$ git update-ref refs/heads/master refs/remotes/git-svn
$ git reset --hard HEAD

5 . Have a look at refs/remotes/heroku/master and at refs/remotes/git-svn. Are there changes in the Git repository that are not present in refs/remotes/git-svn? If yes, cherry-pick them one-by-one. Also have a look at your backup branch (only at commits without git-svn-id), if they are not in SVN yet, cherry-pick them too.

6 . Now you have some changes in master that are not in SVN yet. Run

$ git svn dcommit

to push them to SVN.

7 . Now your SVN-related branch is fully repaired and has all the changes. If I understand correctly, you want the same content in the Git repository. Better replace refs/remotes/heroku/master with current master contents:

$ git push heroku master --force

Now your Git repository has the same contents as SVN repository.

To avoid these problems in future make sure that you never push commits without git-svn-id to Git (i.e. that when you run "git push" your master consists of commits with git-svn-id signatgures only -- if not -- run "git svn dcommit" to push them to SVN first).

这篇关于git-svn-id在某些提交中丢失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆