如何循环运行 svn update 以将提交导入到 git?
当前设置
我正在运行本地 git 存储库,同时在同一文件夹中执行 svn 签出。每当 svn 服务器上发生新情况时,我都会运行 svn update
来下载提交。然后我 git add && git commit 将整个更改集提交到 git 存储库。
任务
我想单独检查每个提交,以便能够 git add && git commit 更改以及来自 svn 的相应提交消息。
想法
我已经发现我可以使用 svnversion 来检索工作副本和服务器的修订号。
// svnversion -h
usage: svnversion [OPTIONS] [WC_PATH [TRAIL_URL]]
Produce a compact 'version number' for the working copy path
WC_PATH. TRAIL_URL is the trailing portion of the URL used to
determine if WC_PATH itself is switched (detection of switches
within WC_PATH does not rely on TRAIL_URL). The version number
is written to standard output. For example:
$ svnversion . /repos/svn/trunk
4168
The version number will be a single number if the working
copy is single revision, unmodified, not switched and with
an URL that matches the TRAIL_URL argument. If the working
copy is unusual the version number will be more complex:
4123:4168 mixed revision working copy
4168M modified working copy
4123S switched working copy
4123P partial working copy, from a sparse checkout
4123:4168MS mixed revision, modified, switched working copy
...
注意
我很乐意与您讨论解决该任务的想法。
稍后的设置还将包括svn externals,这就是为什么我无法通过git-svn签出svn存储库。
Current setup
I am running a local git repository in parallel to a svn checkout in the same folder. Whenever something new happens on the svn server I run svn update
to download the commits. Then I git add && git commit
the whole set of changes to the git repository.
Task
I want to checkout each commit separately to being able to git add && git commit
the change with the corresponding commit message from svn.
Ideas
I already found out that I can use svnversion
to retrieve the revision numbers of the working copy and the server.
// svnversion -h
usage: svnversion [OPTIONS] [WC_PATH [TRAIL_URL]]
Produce a compact 'version number' for the working copy path
WC_PATH. TRAIL_URL is the trailing portion of the URL used to
determine if WC_PATH itself is switched (detection of switches
within WC_PATH does not rely on TRAIL_URL). The version number
is written to standard output. For example:
$ svnversion . /repos/svn/trunk
4168
The version number will be a single number if the working
copy is single revision, unmodified, not switched and with
an URL that matches the TRAIL_URL argument. If the working
copy is unusual the version number will be more complex:
4123:4168 mixed revision working copy
4168M modified working copy
4123S switched working copy
4123P partial working copy, from a sparse checkout
4123:4168MS mixed revision, modified, switched working copy
...
Note
I would be happy to discuss ideas with you to solve the task.
A later setup would also include svn externals which is why I cannot checkout the svn repository via git-svn.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我曾经创建过一个像 shell 脚本这样的“持续集成”,它基本上是一个“
但我只是从内存中写的,也许还有一些其他消息
svn up
可能会产生”。I once created a "continous integration" like shell script which was basically an
But I write this only from memory, maybe there are some other messages which
svn up
may produce`.您可能还需要研究两个选项:
SmartGit
SmartGit 是 Subversion + Git 客户端,这意味着 SmartGit 可与本地 Git 存储库配合使用,但您可以将 svn 存储库添加为远程存储库(类似于 git 远程存储库)。 SmartGit 在功能方面比 git-svn 优越得多。有关更多详细信息,请参阅SmartGit 与 git-svn 比较。
特别是,SmartGit 确实很好地支持 git 子模块和 svn 外部模块,因此您甚至可以混合使用它们。
SmartGit 是专有软件,但非商业用途免费。
SubGit
SubGit 是服务器端解决方案。这意味着您必须安装 SubGit 并将其连接到您的 Subversion 存储库,这基本上包括两个步骤:
通过 SubGit 将 SVN 存储库初始转换为新创建的 Git 存储库。
安装 SubGit 特定的钩子,这些钩子在每次 git 推送时都会触发,这样每个更改都会在 Git 和 SVN 存储库之间同步。
有关更多详细信息,您可以参考 SubGit 文档。
SubGit 是专有软件。 SubGit 对于最多 10 名提交者的小型团队以及学术和开源项目是免费的。
SubGit 还可以作为 Bitbucket Server 的附加组件,要了解更多信息,请查看 此处。
免责声明:
我是 SubGit 开发人员,我与 SmartGit 开发人员保持密切联系。但这两个项目似乎与您的具体案例非常相关。希望您会发现我的评论有帮助。
There are two more options you might want to investigate:
SmartGit
SmartGit is Subversion + Git client, that means SmartGit works with local Git repository but you can add svn repository as a remote (similar to git remotes). SmartGit is much more superior than git-svn feature-wise. For more details please refer to SmartGit vs. git-svn comparison.
In particular SmartGit does support both git submodules and svn externals pretty well, so you can even mix them.
SmartGit is proprietary software but it's free for non-commercial usage.
SubGit
SubGit is the server-side solution. That means you have to install SubGit and connect it to your Subversion repository that basically includes two steps:
Perform initial translation of SVN repository via SubGit to freshly created Git repository.
Install SubGit specific hooks which are triggered on every
git push
, so every change get synchronized between Git and SVN repositories.For more details you may refer to SubGit documentation.
SubGit is proprietary software. SubGit is free for small teams with up to 10 committers and for academic and open-source projects.
SubGit is also available as an add-on for the Bitbucket Server, to find out more check out here.
DISCLAIMER:
I'm SubGit developer and I work in a close contact with SmartGit developers. But these two projects seem very relevant to your particular case. Hope you'll find my comment helpful.
那么你可以尝试 git svn ,它的唯一目的是同时使用 SVN 和 Git。
不要直接使用
svn
。这是设置和使用 SVN 和 Git 所需的全部内容。http://progit.org/book/ch8-1.html
Well you can try
git svn
whose sole purpose is to work with SVN and Git simultaneously.Dont use
svn
directly. Here is all you need to setup and work with SVN and Git.http://progit.org/book/ch8-1.html