[英]How do I fix this git commit log?
I have a repository on Bitbucket. 我在Bitbucket上有一个存储库。 I kinda screwed up the commit log when I tried to squash the commits
c265825
and 0a1837e
: 当我试图
c265825
提交c265825
和0a1837e
时,我有点搞砸了提交日志:
Trying to squash these commits resulted in 0942142
, which is basically empty. 试图
0942142
这些提交导致0942142
,这基本上是空的。 What I mean is if I try and view that commit it shows no files changed, which could be normal for a "merge" commit - I don't know. 我的意思是,如果我尝试查看提交它显示没有文件更改,这可能是正常的“合并”提交 - 我不知道。
Obviously I need to fix things like this before pushing to Bitbucket, but how can I fix it after the fact? 显然我需要在推送到Bitbucket之前修复这样的事情,但是我怎么能在事后解决呢? I'd like to squash
0942142
, c265825
and 0a1837e
if possible so it looks like a single commit called "Removed unused files." 如果可能的
0942142
,我想0942142
, c265825
和0a1837e
,所以它看起来像一个名为“删除未使用的文件”的提交。
PS: This is a private repo (for now), so nobody has pulled any of these changes (yet). PS:这是一个私人仓库(目前),所以没有人撤消任何这些变化(尚未)。
Edit: TheBuzzSaw's answer below is correct for squashing every commit since 0a1837e
. 编辑:下面的BuzzSaw答案对于
0a1837e
自0a1837e
以来的每次提交都是正确的。 I wanted to just squash those three commits and keep the rest of the history, however (the screenshot is a mockup - not representative of actual changes). 我想只是压缩这三个提交并保留历史的其余部分(截图是一个模型 - 不能代表实际的变化)。 So I had to do this:
所以我必须这样做:
git reset --hard HEAD~7
git cherry-pick -n 0a1837e..c265825
git cherry-pick -n -m 1 0942142
git commit -m "Removed unused files"
git cherry-pick 8f8308b
git cherry-pick f7b14f5
git cherry-pick bb90ff9
git cherry-pick 976985d
git cherry-pick 6f4d0c2
Now my commit log is beautified: 现在我的提交日志被美化了:
git branch area51
git reset --hard HEAD~7
git merge --squash --no-commit area51
git commit -m "My new commit message."
git push -f
git branch -D area51
Adjust as necessary. 根据需要调整。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.