git-svn 树的 git 克隆?

发布于 2024-07-13 13:21:11 字数 394 浏览 6 评论 0原文

我有一个“git-svn”工作树。 我想克隆一个“纯”git repo,然后使用 git push/pull 在 git-svn 树和 git 树之间移动更改,同时还使用 'git svn dcommit/rebase' 在 git-svn 树和 git 树之间移动更改git-svn 树和它所基于的 SVN 存储库。

就使用 git 方法在 git 树之间来回移动东西而言,这似乎工作正常,但是一旦我与 git-svn 树中的 SVN 存储库进行交互,事情就会变得不稳定——要么我在推送时出错,要么在 git 树之间拉动,或者我丢失了 git-svn 树中的提交,或者其他奇怪的情况。

这种类型的SVN是<->吗? git-svn <->; 完全支持 git 工作流程还是我应该停止对这棵树吠叫?

I've got a 'git-svn' working tree. I'd like to clone a "pure" git repo off this, and then use git push/pull to move changes between the git-svn tree and the git tree, while also using 'git svn dcommit/rebase' to move changes between the git-svn tree and the SVN repo it's based on.

This seems to work okay as far as moving things back and forth between the git trees using git methods, but as soon as I interact with the SVN repo in the git-svn tree, things get wonky -- either I get errors when pushing or pulling between the git trees, or I lose commits in the git-svn tree, or other oddness.

Is this type of SVN <-> git-svn <-> git workflow supported at all or should I just quit barking up this tree?

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

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

发布评论

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

评论(6

九八野马 2024-07-20 13:21:11

我为我的一些项目设置了一个桥,但它只是从 git 到 svn 的单向方式(提供 git master 分支的公共只读 SVN 镜像)。 然而,由于它工作正常,它可能会帮助您或在双向场景中为您指明正确的方向,因为我认为是 git->svn 造成了问题,而不是 svn->git:

我的单向场景:github上现有的git存储库,需要git master分支的只读svn镜像

  • 在服务器上创建并初始化目标subversion存储库:

    svnadmin 创建 svnrepo 
      mkdir 主干 
      svn 导入 trunk svn://yoursvnserver/svnrepo 
      rmdir -rf 中继 
      
  • 创建混合 Git-Svn 签出并初始化 Subversion 存储库

    git svn 克隆 svn://yoursvnserver/svnrepo/trunk 
      CD箱 
      git 远程添加 github git://github.com/yourname/repo.git 
      git 获取 github 
      git 分支 tmp $(cat .git/refs/remotes/github/master) 
      git tag -a -m“最后一次获取”最后一次tmp 
      INIT_COMMIT=$(git log tmp --pretty=格式:%H | tail -1) 
      git checkout $INIT_COMMIT 。 
      git 提交 -C $INIT_COMMIT 
      git rebase master tmp 
      git分支-M tmp master 
      git svn dcommit --rmdir --find-copies-harder 
      
  • 更新镜像

    git fetch github 
      git 分支 tmp $(cat .git/refs/remotes/github/master) 
      git tag -a -m“上次获取”newlast tmp 
      git rebase --onto master 最后的 tmp 
      git分支-M tmp master 
      git svn dcommit --rmdir --find-copies-harder 
      mv .git/refs/tags/newlast .git/refs/tags/last 
      

googlecode 的这两篇文章可能也会有所帮助:

I have a bridge setup for some of my projects, but it's only one-way from git to svn (providing a public readonly SVN mirror of our git master branch). However, since it works fine it might help you or point you in the right direction in your two-way scenario anyway, as I assume it's git->svn that makes problems, not svn->git:

My one-way scenario: Existing git repository at github, need a readonly svn mirror of the git master branch

  • Create and initialize the target subversion repository on the Server:

    svnadmin create svnrepo
    mkdir trunk
    svn import trunk svn://yoursvnserver/svnrepo
    rmdir -rf trunk
    
  • Create a mixed Git-Svn checkout and initialize subversion repository

    git svn clone svn://yoursvnserver/svnrepo/trunk
    cd trunk
    git remote add github git://github.com/yourname/repo.git
    git fetch github
    git branch tmp $(cat .git/refs/remotes/github/master)
    git tag -a -m "Last fetch" last tmp
    INIT_COMMIT=$(git log tmp --pretty=format:%H | tail -1)
    git checkout $INIT_COMMIT .
    git commit -C $INIT_COMMIT
    git rebase master tmp
    git branch -M tmp master
    git svn dcommit --rmdir --find-copies-harder
    
  • Update the mirror

    git fetch github
    git branch tmp $(cat .git/refs/remotes/github/master)
    git tag -a -m "Last fetch" newlast tmp
    git rebase --onto master last tmp
    git branch -M tmp master
    git svn dcommit --rmdir --find-copies-harder
    mv .git/refs/tags/newlast .git/refs/tags/last
    

This two articles from googlecode might help as well:

俯瞰星空 2024-07-20 13:21:11

可能给您带来麻烦的一件事是 git svn dcommit 会重写它发送到 SVN 的所有提交 - 至少如果它配置为将 SVN 元数据注释添加到提交消息的底部。 因此,您将不得不采用一种流程,其中任何存储库从 git-svn 工作区获取提交都会对其进行变基,从而丢失所有无法存储在 SVN 中的合并历史记录。

One thing that may be causing you trouble is that git svn dcommit will rewrite all the commits it sends to SVN- at least if it's configured to add the SVN metadata note to the bottom of the commit messages. So you will have to adopt a flow where any repositories taking commits from your git-svn workspace rebase against it, losing all the merge history which can't be stored in SVN anyway.

Spring初心 2024-07-20 13:21:11

根据我所看到的,由于 SVN 表示合并的方式,git-svn 不支持此工作流程,将来也不会支持。

Based on what I've seen, this workflow isn't supported with git-svn, and won't be, due to the way SVN represents merges.

無心 2024-07-20 13:21:11

正如我经常在 #git 上说的:

git-svn 就像一辆飞行汽车。 每个人都想要一辆飞行汽车,直到他们意识到飞行汽车无论是作为汽车还是飞机都非常糟糕。

真正的解决方案是尽快完全摆脱 SVN。 使用 git-svn 进行一次性迁移,然后将所有人移过去。 Git 并不难学。

As I've often said on #git:

git-svn is like a flying car. Everybody wants a flying car, until they realize a flying car is pretty bad as either a car or a plane.

The real solution is to get away from SVN entirely, as quickly as possible. Use git-svn for a one-time migrate, then move everyone over. Git is not that hard to learn.

爱,才寂寞 2024-07-20 13:21:11

如果您能够将自定义挂钩安装到 Subversion 存储库中,请考虑使用 SubGit

SubGit 是一个服务器端解决方案,可以自动同步 SVN 和 Git 存储库。 要安装 SubGit,请执行以下操作:

    $ subgit configure $SVN_REPOS
    $ # Adjust $SVN_REPOS/conf/subgit.conf 
    $ #     to specify your branches and tags
    $ # Adjust $SVN_REPOS/conf/authors.txt 
    $ #     to introduce svn author names to their git counterparts
    $ subgit install $SVN_REPOS
    $ ...
    $ INSTALLATION SUCCESSFUL

此时 SubGit 已安装由每个 svn commitgit Push 触发的钩子。 这样 SubGit 就会转换任何传入的修改。

另请参阅与 git-svn 的比较。

If you're able to install custom hooks into Subversion repository, consider using SubGit.

SubGit is a server-side solution that automatically synchronizes SVN and Git repositories. In order to install SubGit do the following:

    $ subgit configure $SVN_REPOS
    $ # Adjust $SVN_REPOS/conf/subgit.conf 
    $ #     to specify your branches and tags
    $ # Adjust $SVN_REPOS/conf/authors.txt 
    $ #     to introduce svn author names to their git counterparts
    $ subgit install $SVN_REPOS
    $ ...
    $ INSTALLATION SUCCESSFUL

At this moment SubGit has installed hooks that are triggered by every svn commit and git push. This way SubGit converts any incoming modification.

See also comparison with git-svn.

画骨成沙 2024-07-20 13:21:11

使用git和git-svn 1.7.1,看来我刚刚做的测试似乎工作得很好。

git svn init [url]
git svn fetch

然后,您必须创建并签出一个虚拟分支,以便能够推送到主分支。

git checkout -b dummy

然后你可以将它克隆(git clone ...)到另一个纯git存储库中,修改它,提交它(git commit)然后推送(git push< /code>) 进入 git-svn 存储库。

回到 git svn 存储库:

git checkout master
git svn dcommit

将提交所有已推送的 git 提交。

Using git and git-svn 1.7.1, it seems that the test I just did seems to work just fine.

git svn init [url]
git svn fetch

you must then create and checkout a dummy branch to be able to push to the master branch.

git checkout -b dummy

Then you can clone it (git clone ...) into another pure git repo, modify it, commit it (git commit) then push (git push) into the git-svn repo.

back to the git svn repo:

git checkout master
git svn dcommit

will commit all git commits that have been pushed.

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