有没有办法“坚持”将 git 存储库与 SVN 同步?

发布于 2024-10-23 23:26:09 字数 186 浏览 3 评论 0原文

从我在网上找到的信息来看,似乎使用 git svn 并不是“持久”的。

意思是,如果我 git svn clone 一个存储库,然后推送到 master 并在单独的文件夹中重新拉取新副本,则新副本根本不知道 svn,并且无法用于与 SVN 同步无需重新应用svn clone

有办法解决这个问题吗?

From what I could find around the web, it seems that using git svn is not "persisted".

Meaning, if I git svn clone a repository, then push to master and repull a fresh copy in a separate folder, the fresh copy is not aware of svn at all, and cannot be used to synchronize with SVN without reapplication of svn clone.

Is there a way around this issue?

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

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

发布评论

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

评论(3

瘫痪情歌 2024-10-30 23:26:09

克隆本质上只是初始化一个新的 git 存储库,设置 origin 远程,运行 git fetch,并根据远程存储库的 HEAD 创建一个分支>。这些操作都不会查看远程存储库中的 .git/svn 信息 - 我认为除了 refsobjects之外的所有内容远程存储库的 git 目录中的 >HEAD 被视为私有。

至于解决这个问题的方法,你总是可以rsync -ascp -r远程存储库而不是克隆它,这应该可行 - 所有 Subversion 元数据都应该被复制。

然而,就我个人而言,我总是发现只有一个 git svn 克隆存储库并从中执行 git svn dcommit 并在需要时推送回该存储库不会那么混乱将任何内容提交给 Subversion。那么那些其他存储库只是普通的 git 存储库,您无需担心 git svn 的任何限制,直到您推回到 git svn 克隆,位于您通常需要进行一些变基操作......

A clone essentially just initializes a new git repository, sets up the origin remote, runs git fetch, and creates a branch based on the remote repository's HEAD. None of these operations look at the .git/svn information in the remote repository - I think that everything apart from refs, objects and HEAD in a remote repository's git directory is regarded as private.

As for a way around that, you could always rsync -a or scp -r the remote repository instead of cloning it, which should work - all the Subversion metadata should be copied.

However, personally I've always found it less confusing to just have one git svn cloned repository that I do git svn dcommit from, and push back to that repository whenever I want to commit anything to Subversion. Then those other repositories are just normal git repositories and you don't need to worry about any of the restrictions of git svn until you push back to the git svn clone, at which point you normally need to do some rebasing...

薆情海 2024-10-30 23:26:09

我发现最简单的方法是使用与创建第一个 git-svn 克隆相同的参数来 git svn init 克隆,然后是 update-ref 和 dcommit。

假设你做了:

git svn clone -s svn://服务器/网站

.. 创建第一个存储库。然后你可以克隆它:

git clone website website2
cd website2 

初始化 git-svn:

git svn init -s svn://server/website

现在你必须更新 git-svn 远程引用以指向最后一次提交,例如:

git update-ref refs/remotes/trunk refs/remotes/origin/HEAD

然后只需执行 git svn dcommit 即可重建 git-svn revmap。

git svn dcommit

您应该看到如下输出:

git svn dcommit
Rebuilding .git/svn/refs/remotes/trunk/.rev_map.dbae88...
r1 = a9cf429caa11ba5433a6526c2d327de6db2605d1
r2 = 2811ffb78c0a9e0a74208758367044710c1c0159
r4 = 1b787f296aeb98806875ca4f2bde67131720cd57
r9 = 991400ef398fad17ca14253467997d4764561cff
r11 = c5984281dd185d3dbb3bf3fa26f168f34d4e4b53
r13 = aa7678d2f9b5f87152ab09a59ea11a4643e84b6c
r14 = 1c91c959e3bbd2d41dd001a670d01abef29ae1ad
Done rebuilding .git/svn/refs/remotes/trunk/.rev_map.dbae88...
Committing to svn://server/website/trunk ...

有关更多背景信息,请查看 这篇文章,尤其是第 5 点。

I find the easiest way is to git svn init the clone with the same parameters you used for creating the first git-svn clone, followed by an update-ref and a dcommit.

Say you did:

git svn clone -s svn://server/website

.. to create the first repo. Then you would clone it:

git clone website website2
cd website2 

Initialize git-svn:

git svn init -s svn://server/website

Now you've got to update the git-svn remote reference to point at the last commit, for example:

git update-ref refs/remotes/trunk refs/remotes/origin/HEAD

And then just do an git svn dcommit to rebuild the git-svn revmap.

git svn dcommit

You should see some output like this:

git svn dcommit
Rebuilding .git/svn/refs/remotes/trunk/.rev_map.dbae88...
r1 = a9cf429caa11ba5433a6526c2d327de6db2605d1
r2 = 2811ffb78c0a9e0a74208758367044710c1c0159
r4 = 1b787f296aeb98806875ca4f2bde67131720cd57
r9 = 991400ef398fad17ca14253467997d4764561cff
r11 = c5984281dd185d3dbb3bf3fa26f168f34d4e4b53
r13 = aa7678d2f9b5f87152ab09a59ea11a4643e84b6c
r14 = 1c91c959e3bbd2d41dd001a670d01abef29ae1ad
Done rebuilding .git/svn/refs/remotes/trunk/.rev_map.dbae88...
Committing to svn://server/website/trunk ...

For more background, have a look at this post, especially point 5.

酒浓于脸红 2024-10-30 23:26:09

GIT-SVN 片段: http://marcocattai.posterous.com/git-svn-snippets

我希望它们有用。

GIT-SVN SNIPPETS: http://marcocattai.posterous.com/git-svn-snippets

I hope they're useful.

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