简体   繁体   中英

git - modify commit (interactive rebase) that does not SEEM to have a previous commit?

When I run git fsck I have some bad commits that I need to fix:

$ git fsck
Checking object directories: 100% (256/256), done.
error in commit 60707e738f5b4330147fff34d7ddc734eea4a577: missingSpaceBeforeDate: invalid author/committer line - missing space before date
error in commit c60d233e8296f9c7a1f6e50719e59bac6fdd272f: badDate: invalid author/committer line - bad date
Checking objects: 100% (163912/163912), done.

I tried to follow the answer in how-do-i-modify-a-specific-commit but when I run:

git rebase --interactive 'c60d233e8296f9c7a1f6e50719e59bac6fdd272f^'

I don't see c60d23 in the list of commits to edit, so there is nothing for me to "fix", since the commit in question is not on that list.

Any ideas on how I can fix this bad date error on this commit? Any third party tools that may help?

Thanks!

=====Update based on @hlovdal Answer=====

I ran git branch --contains c60d23 but it does not return anything.

I also ran:

git tag fsck-bad-60707e73 60707e73
git tag fsck-bad-c60d233e c60d233e
gitk --all &

And this is what I see: 在此处输入图像描述

But since that commit does not exist in a branch, I don't know how to rebase it:(

I don't see c60d23 in the list of commits to edit, so there is nothing for me to "fix", since the commit in question is not on that list.

What commits come up in the list with interactive rebase is dependent on which branch which is checked out when you run the interactive command. It is not unthinkable that the commit c60d23 is present on some other branch and not visible from your branch (it could maybe also be a dangling commit).

So start by finding out which branches that contains the commit by running

git branch --contains c60d23

Also/alternatively you can look at the commits with gitk

git tag fsck-bad-60707e73 60707e73
git tag fsck-bad-c60d233e c60d233e
gitk --all &

and then press F2 to locate those two commits. From there you should be able to see which branches that contains those problematic commits.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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