编辑数百个Git提交消息的最快方法是什么? [英] What's the fastest way to edit hundreds of Git commit messages?

查看:85
本文介绍了编辑数百个Git提交消息的最快方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个相当大的Git仓库,其中有1000个提交,最初是从SVN导入的。在公开我的回购之前,我想清理几百条提交的消息,这些消息在我的新回购中没有意义,并且删除所有添加的git-svn信息文本。



我知道我可以使用'git rebase -i'然后'git commit --amend'来编辑每个单独的提交消息,但是要编辑数百条消息,这是一个巨大的痛苦在你知道什么。

是否有更快的方式来编辑所有这些提交消息?理想情况下,我会将所有提交消息列在单个文件中,我可以在一个位置编辑它们。



谢谢!




  • 执行第一次导入。

    / li>
  • 将所有提交导出为文本:

      git format-patch -10000 

    数字应该超过整个提交。这将创建大量名为 NNNNN-commit-description.patch 的文件。


  • 使用一些脚本编辑这些文件。
    (不要触摸它们中的任何内容,除了带提交消息的顶部)。
  • 将编辑的文件复制或移动到空的git repo或分支。

  • 导入所有编辑的提交:

      git am * .patch 




这只适用于单分支,但效果很好。


I have a fairly large Git repository with 1000s of commits, originally imported from SVN. Before I make my repo public, I'd like to clean up a few hundred commit messages that don't make sense in my new repo, as well as to remove all that git-svn informational text that got added.

I know that I can use 'git rebase -i' and then 'git commit --amend' to edit each individual commit message, but with hundreds of messages to be edited, that's a huge pain in the you-know-what.

Is there any faster way to edit all of these commit messages? Ideally I'd have every commit message listed in a single file where I could edit them all in one place.

Thanks!

解决方案

This is easy to do as follows:

  • Perform first import.
  • Export all commits into text:

    git format-patch -10000
    

    Number should be more than total commits. This will create lots of files named NNNNN-commit-description.patch.

  • Edit these files using some script. (Do not touch anything in them except for top with commit messages).
  • Copy or move edited files to empty git repo or branch.
  • Import all edited commits back:

    git am *.patch
    

This will work only with single branch, but it works very well.

这篇关于编辑数百个Git提交消息的最快方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆