【问题标题】:How to retain git authorship and commit date when using git-svn to push to a subversion repo?使用 git-svn 推送到 subversion repo 时如何保留 git 作者身份和提交日期?
【发布时间】:2012-07-24 11:18:40
【问题描述】:

我们从一个新的、空的 subversion 存储库和一个现有的 git 存储库开始,我想“推送”并保留所有历史记录和作者身份(如果可能的话,甚至只是用户名)。

使用“git svn dcommit”我可以在 subversion repo 的历史记录中看到修订 cmets,但作者详细信息默认为我在 subversion 中的用户名,提交日期变为 todays 日期,即push 而不是 git 中的初始提交。

是否有方法可以覆盖这些感兴趣的属性,就像 BZR->SVN,使用 bazaar.conf 覆盖和修改 pre-revprop-change 挂钩,但这次是 Git?

谢谢。

【问题讨论】:

    标签: git svn git-svn revision-history


    【解决方案1】:

    你不能用 git-svn 保留作者和日期(你也不能用它来保留忽略、匿名分支和复杂的历史)。

    为了将 Git 存储库转换为 SVN,保留所有使用 SubGit 的项目:

    $ svnadmin create svn.repo
    
    $ subgit configure svn.repo
    
    $ #edit svn.repo/conf/subgit.conf ('git.default.repository' option) 
    to set path to your bare Git repository (the repository you on the server
    or you can prepare new bare repository
    with "git clone --bare <Git URL> path/to/bare/git/repo")
    
    $ #optionally prepare svn.repo/conf/authors.txt file
    to configure custom authors mapping
    
    $ subgit install
    

    安装后 SubGit 会同步 SVN 仓库 svn.repo 和 Git 仓库 path/to/bare/git/repo 并保持同步,这样任何对 SVN 的提交都会导致 Git 提交,反之亦然(同步由hooks 和并发安全,所以你仍然可以继续使用 Git)。

    停止连续同步运行

    $ subgit uninstall svn.repo
    

    【讨论】:

    • 很棒的发现。我们的要求只是将我们的 git 开发分支推送到 /trunk 并将其作为一个点发布分支,因此不需要双向使用,但这完美地工作。谢谢德米特里。
    猜你喜欢
    • 1970-01-01
    • 2015-08-22
    • 1970-01-01
    • 2012-04-28
    • 1970-01-01
    • 2015-06-25
    • 2016-01-04
    • 2013-12-17
    • 1970-01-01
    相关资源
    最近更新 更多