用空的提交消息重新激活git历史记录 [英] Rebasing a git history with empty commit messages
问题描述
我最近用 git svn
转换了一个svn仓库。不幸的是,svn历史记录有一些空的提交消息。这是一个问题,当我在没有提交消息的情况下在最近的提交之前重新绑定和编辑/重新提交提交。
$ p $
$ git rebase -i d01
[detached HEAD ff9839c] asdf
2个文件已更改,9个插入(+),0个删除( - )
由于提交消息为空而终止提交。
无法应用054e890 ...
$ git分支
*(不分支)
主人
$ git commit --amend
致命的:你正处于樱桃选择的中间 - 不能修改。
在这个例子中,我使用空的提交消息为第二次最近的提交提交了一条提交消息,重新绑定在最近的提交时停止,提交消息为空。
我想一次编辑所有提交空信息的提交。有没有办法可以做到这一点?也许我可以用一个空的提交消息来改变所有提交,让提交消息先是空的?
有一些模板的消息,你可以这样做:
git filter-branch -f --msg-filter'
如果[-n$ msg]读取msg
;然后
echo$ msg
else
echo提交消息为空
fi'
I recently converted an svn repository with git svn
. Unfortunately the svn history has a number of empty commit messages. This is a problem when I rebase and edit/reword a commit before the most recent commit without a commit message.
$ git rebase -i d01
[detached HEAD ff9839c] asdf
2 files changed, 9 insertions(+), 0 deletions(-)
Aborting commit due to empty commit message.
Could not apply 054e890...
$ git branch
* (no branch)
master
$ git commit --amend
fatal: You are in the middle of a cherry-pick -- cannot amend.
In this example I made a commit message for the second most recent commit with an empty commit message and the rebasing stopped on the most recent commit with an empty commit message.
I would like to edit all of the commits with empty messages at once. Is there a way I can do that? Maybe I can change all commits with a empty commit message to have the commit message "empty" first?
To replace empty commit messages with some template, you can do something like this:
git filter-branch -f --msg-filter '
read msg
if [ -n "$msg" ] ; then
echo "$msg"
else
echo "The commit message was empty"
fi'
这篇关于用空的提交消息重新激活git历史记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!