我可以使用本地跟踪git

编程入门 行业动态 更新时间:2024-10-26 14:36:40
本文介绍了我可以使用本地跟踪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 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 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:

  • Re-cloned tracked-svn/trunk in a fresh git-svn repo.
  • Added my old git-svn repo as a remote to the fresh repo. (eg. git remote add -f up-to-date /path/to/repo)
  • git merge remotes/up-to-date/master
  • 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

    本文发布于:2023-11-03 06:51:17,感谢您对本站的认可!
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:可以使用   git

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!