简体   繁体   English

Svn2git:将修订号添加到 git commit 标题

[英]Svn2git: Add revision number to git commit title

I want to add the svn revision to every git commit title, so can I can see every Revision in each commit in the history of our Team Foundation Server.我想将 svn 修订版添加到每个 git 提交标题,这样我就可以在 Team Foundation Server 的历史记录中看到每个提交中的每个修订版。

I already tried editing a commit with "--amend", but this way it just makes a new commit (and the history becomes incorrect).我已经尝试使用“--amend”编辑提交,但这样它只会进行新的提交(并且历史记录变得不正确)。 Also I dont wanna edit every commit one by one.我也不想一一编辑每个提交。 Screenshot of what I wanna archieve The Screenshot shows what I did with --ammend.我想要存档的截图 截图显示了我用 --ammend 做了什么。

I'm using svn2git for the Migration.我正在使用 svn2git 进行迁移。

There are pleny tools called svn2git .有很多工具叫做svn2git If you are not using the KDE one from https://github.com/svn-all-fast-export/svn2git .如果您没有使用来自https://github.com/svn-all-fast-export/svn2git的 KDE。 I strongly recommend using that svn2git tool.我强烈推荐使用那个svn2git工具。 It is the best I know available out there and it's very flexible in what you can do with its rules files.这是我所知道的最好的,而且它的规则文件可以非常灵活地执行。

You will easily be able to configure it for your layout to get the result you want and expect.您将能够轻松地为您的布局配置它以获得您想要和期望的结果。

If you are not 100% about the history of your repository, svneverever from http://blog.hartwork.org/?p=763 is a great tool to investigate the history of a SVN repository when migrating it to Git.如果您不是 100% 了解存储库的历史, svneverever http://blog.hartwork.org/?p=763中的svneverever是一个很好的工具,可以在将 SVN 存储库迁移到 Git 时调查其历史记录。

With the latest merged pull requests you can even fulfill your request with it.使用最新的合并拉取请求,您甚至可以用它来满足您的请求。 Just get and compile the sources or wait until a new release is done.只需获取并编译源代码或等待新版本完成即可。 Then you can use the --add-metadata switch in combination with the --msg-filter switch which is applied after --add-metadata , so in the --msg-filter process you can take the automatically added metadata with the revision number and move or copy it to the end of the first line of the commit message.然后,您可以将--add-metadata开关与在--add-metadata之后应用的--msg-filter开关结合使用,因此在--msg-filter过程中,您可以将自动添加的元数据与修订版一起使用number 并将其移动或复制到提交消息的第一行的末尾。

You can have several options to do it:您可以有多种选择来执行此操作:

  1. Modify the commit message and store the content in your commit message.修改提交消息并将内容存储在提交消息中。
  2. Add metadata to the commit.将元数据添加到提交。

Modify the commit message

Like you mentioned in your question is you do a git commit --amend its actually a rebase .就像你在问题中提到的那样,你做了一个git commit --amend它实际上是一个rebase rebase modify the commit and change the SHA-1. rebase修改提交并更改 SHA-1。

You wish to avoid it, so you will need to set the message before committing.您希望避免它,因此您需要在提交之前设置消息。
Here is why it's happening, since the message is part of the metadata which calculated when generating the SHA-1.这就是它发生的原因,因为消息是生成 SHA-1 时计算的元数据的一部分。

在此处输入图片说明


Add metadata to the commit.

If you want to add extra data to the commit after you have committed the nest way is simply to add notes .如果您想在提交向提交添加额外的数据,嵌套方法就是添加notes Notes is not part of the metadata used to generate the SHA-1 so you can add it after the commit was made. Notes 不是用于生成 SHA-1 的元数据的一部分,因此您可以在提交后添加它。

git notes add -m 'Old commit is: xxxxxx'

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

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