有没有办法“坚持”将 git 存储库与 SVN 同步?
从我在网上找到的信息来看,似乎使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
克隆本质上只是初始化一个新的 git 存储库,设置
origin
远程,运行git fetch
,并根据远程存储库的HEAD
创建一个分支>。这些操作都不会查看远程存储库中的.git/svn
信息 - 我认为除了refs
、objects
和之外的所有内容远程存储库的 git 目录中的 >HEAD
被视为私有。至于解决这个问题的方法,你总是可以
rsync -a
或scp -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, runsgit fetch
, and creates a branch based on the remote repository'sHEAD
. None of these operations look at the.git/svn
information in the remote repository - I think that everything apart fromrefs
,objects
andHEAD
in a remote repository's git directory is regarded as private.As for a way around that, you could always
rsync -a
orscp -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 dogit 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 ofgit svn
until you push back to thegit svn
clone, at which point you normally need to do some rebasing...我发现最简单的方法是使用与创建第一个 git-svn 克隆相同的参数来 git svn init 克隆,然后是 update-ref 和 dcommit。
假设你做了:
.. 创建第一个存储库。然后你可以克隆它:
初始化 git-svn:
现在你必须更新 git-svn 远程引用以指向最后一次提交,例如:
然后只需执行 git svn dcommit 即可重建 git-svn revmap。
您应该看到如下输出:
有关更多背景信息,请查看 这篇文章,尤其是第 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:
.. to create the first repo. Then you would clone it:
Initialize git-svn:
Now you've got to update the git-svn remote reference to point at the last commit, for example:
And then just do an git svn dcommit to rebuild the git-svn revmap.
You should see some output like this:
For more background, have a look at this post, especially point 5.
GIT-SVN 片段: http://marcocattai.posterous.com/git-svn-snippets
我希望它们有用。
GIT-SVN SNIPPETS: http://marcocattai.posterous.com/git-svn-snippets
I hope they're useful.