当前设置
我在同一文件夹中同时运行本地 git 存储库和 svn check out 。每当 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 checkout svn 存储库。
最佳答案
您可能还想研究另外两个选项:
-
SmartGit 是 Subversion + Git 客户端,这意味着 SmartGit 与本地 Git 存储库一起工作,但您可以将 svn 存储库添加为远程(类似于 git remotes)。 SmartGit 在功能方面比 git-svn 优越得多。更多详情请引用SmartGit vs. git-svn comparison .
特别是 SmartGit 确实很好地支持 git 子模块和 svn 外部,所以你甚至可以混合使用它们。
SmartGit 是专有软件,但对于非商业用途是免费的。
-
SubGit 是服务器端解决方案。这意味着您必须安装 SubGit 并将其连接到您的 Subversion 存储库,这基本上包括两个步骤:
通过 SubGit 将 SVN 存储库初始转换为新创建的 Git 存储库。
安装在每次
git push
时触发的特定于 SubGit 的钩子(Hook),这样 Git 和 SVN 存储库之间的每个更改都会同步。
更多详情可以引用SubGit documentation .
SubGit 是专有软件。 SubGit 对于最多 10 名提交者的小型团队以及学术和开源项目是免费的。 SubGit 也可作为 Bitbucket Server 的附加组件使用,要了解更多信息,请查看 here .
免责声明:
我是 SubGit 开发人员,并且与 SmartGit 开发人员保持密切联系。但这两个项目似乎与您的特定案例非常相关。希望我的评论对您有所帮助。
关于git - 如何在循环中运行 svn update 以将提交导入到 git?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8389693/