我可以使用本地跟踪git-svn分支来恢复SVN存储库中丢失的提交吗? [英] Can I recover lost commits in a SVN repository using a local tracking git-svn branch?

查看:122
本文介绍了我可以使用本地跟踪git-svn分支来恢复SVN存储库中丢失的提交吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用git-svn跟踪的SVN回购最近已损坏,备份已恢复。然而,在经济复苏中,一周的承诺失败了。是否有可能在我的本地git仓库中使用 git-svn dcommit 来恢复那些丢失的提交?运行 git-svn dcommit 与SVN中最后一次恢复提交的SHA1是否足够?例如

 > svn info http:// tracked-svn / trunk | sed -ns / Revision:// p
252
> git log --grep =git-svn-id:。* @ 252--format = oneline | cut -f1 -d
55bb5c9cbb5fe11a90ec2e9e1e0c7c502908cf9a
> git svn dcommit 55bb5c9cbb5fe11a90ec2e9e1e0c7c502908cf9a

或者 git-svn-id 需要从预期的提交中剥离出来

我试着用 - dry-run 但不知道它是否会尝试提交所有提交:

 > git svn dcommit --verbose --dry-run 55bb5c9cbb5fe11a90ec2e9e1e0c7c502908cf9a 
承诺为http:// tracked-svn / trunk ...
由于您提供了修订版参数,因此在分离的HEAD上提交了dcommit。
重写的提交是:55bb5c9cbb5fe11a90ec2e9e1e0c7c502908cf9a

感谢您的帮助。

解决方案

以下是我如何达到我想要的: 在新的git-svn仓库中重新克隆 http:// tracked-svn / trunk

  • 添加了旧的git-svn作为新鲜回购的远程回购。 (例如 git remote add -f最新版/ path / to / repo
  • git merge remotes / up-to-date / master

  • git svn dcommit

  • 在我的旧回购库中重新生成时不会出现任何错误,并且dcommit可按预期工作。



    不是恢复提交的最佳方式,但它使我得到了我想要的。


    A SVN repo I use git-svn to track was recently corrupted and a backup was recovered. However, a week's worth of commits were lost in the recovery. Is it possible to recover those lost commits using git-svn dcommit on my local git repo? Is it sufficient to run git-svn dcommit with the SHA1 of the last recovered commit in SVN? eg.

    > svn info http://tracked-svn/trunk | sed -n "s/Revision: //p"
    252
    > git log --grep="git-svn-id:.*@252" --format=oneline | cut -f1 -d" "
    55bb5c9cbb5fe11a90ec2e9e1e0c7c502908cf9a
    > git svn dcommit 55bb5c9cbb5fe11a90ec2e9e1e0c7c502908cf9a
    

    Or will the git-svn-id need to be stripped from the intended commits?

    I tried this using --dry-run but couldn't tell whether it would try to submit all commits:

    > git svn dcommit --verbose --dry-run 55bb5c9cbb5fe11a90ec2e9e1e0c7c502908cf9a
    Committing to http://tracked-svn/trunk ...
    dcommitted on a detached HEAD because you gave a revision argument.
    The rewritten commit is: 55bb5c9cbb5fe11a90ec2e9e1e0c7c502908cf9a
    

    Thanks for your help.

    解决方案

    Here is how I achieved what I wanted:

    1. Re-cloned http://tracked-svn/trunk in a fresh git-svn repo.
    2. Added my old git-svn repo as a remote to the fresh repo. (eg. git remote add -f up-to-date /path/to/repo)
    3. git merge remotes/up-to-date/master
    4. git svn dcommit

    Rebasing on my old repo gives no errors, and dcommit works as expected.

    This might not be the best way to recover commits, but it got me what I wanted.

    这篇关于我可以使用本地跟踪git-svn分支来恢复SVN存储库中丢失的提交吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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