简体   繁体   English

SubGit导入时在Git提交消息中添加Subversion修订版

[英]Add Subversion revision in Git commit message on SubGit import

Im am using a simple on-time import to migrate an existing SVN repository to GIT. 我正在使用一个简单的按时导入将现有的SVN存储库迁移到GIT。

$ subgit import --svn-url http://svn/repo repo.git

Everything works fine, but is there any chance to include the corresponding SVN revision number in each GIT commit created by SubGit? 一切正常,但是是否有机会在SubGit创建的每个GIT提交中包含相应的SVN版本号?

Currently there's no such functionality, but there's something that has similar effect. 当前没有这种功能,但是有些功能具有相似的作用。

When you set up the access to the Git repository, after cloning it you can follow this recommendation from SubGit book . 设置对Git存储库的访问权限后,在克隆之后,您可以遵循SubGit book中的建议。 Ie edit .git/config file to set 即编辑.git/config文件进行设置

[remote "origin"]
...
fetch = +refs/svn/map:refs/notes/commits

and then run 然后运行

git fetch

To download the Git notes . 下载Git笔记 After that "git log" will display revision numbers. 之后,“ git log”将显示修订号。

Moreover, if you need to find revision number by SHA-1 hash and vice versa from a script, you can run 此外,如果需要从脚本中通过SHA-1哈希查找修订号,反之亦然,则可以运行

git log --all --format="%H %N"

The output may look like: 输出可能如下所示:

669d570bc561023034c7b28fd6e0a369662b1258 
aa628cf9ac100bb144f50490d403e2dcacfd0842 r3624 trunk

db76bb8572f62169a9a28532890610b5a6c234c9 
c5b2a475ce5fce72a620064b7b9507af2ec10212 r3623 branches/feature

a5938100859e6d1a245f84907acd33cf8092eb96 
086773418197047b523cda6e892441b1364c56f7 r3622 branches/feature

f47b87de14a9d476cd8efd708e0571512875faf9 
fb8edc1b9ad1668c1930f8db6f6e43c08d02baa1 
64fd8ef37200438dd4068255ff56ac09e73a8259 
00cc3cc581593c90155569fadb47c0d99565a362 
7ca753c7c8ae572ceff235eb8f68d1e8805f0bc4 r3621 branches/feature

827a04ebede055a6847b52d416efe04b9e81511e r3620 branches/feature

After that you can use grep, awk, sed and other tools you like to find SHA1 by revision and vice versa. 之后,您可以使用grep,awk,sed和其他您喜欢的工具通过修订来查找SHA1,反之亦然。

Lines without revision numbers correspond to Git notes themselves (Git notes for commits are stored in other Git commits) and just Git commits not annotated with notes, ie not translated from SVN. 没有修订号的行对应于Git注释本身(提交的Git注释存储在其他Git提交中),只是没有注释的Git提交,即未从SVN转换而来。 Empty lines are added after commits with notes because the notes contain LF character at the end; 提交注释后添加空行,因为注释末尾包含LF字符; grep and awk are great at ignoring them. grep和awk非常擅长忽略它们。

I hope this is more convenient than if the revisions were put directly into the commit message. 我希望这比将修订版本直接放入提交消息中更为方便。

Finally I'll add that this all works not only for import but also for continuous synchronization as well. 最后,我将添加所有功能,不仅适用于导入,而且还适用于连续同步。

I'm one of SubGit developers. 我是SubGit开发人员之一。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM