Git LFS迁移生成提交无效:缺失日期前空格且日期异常
Fixing Invalid Commit from Git LFS Migrate with Missing Space Before Date Error
Let's break down what's going on here: when you ran git lfs migrate import --no-rewrite luca/models/weights/yolov5m.pt, Git LFS generated a commit with broken author/committer metadata—specifically, there's a missing space between your email address and the date string. Git couldn't parse this messed-up line correctly, so it defaulted the date to the Unix epoch (Thu Jan 1 00:00:00 1970 +0000) and threw that missingSpaceBeforeDate error during git fsck.
Here's how to fix this, depending on where the bad commit sits in your history:
1. If the bad commit is your latest (unpushed) commit
- First, run
git show 1e39456again to check the exact author line—you’ll likely see something likeAuthor: Luca<luca@example.com>Thu Jan 1...(no space after the email closing bracket or before the date). - Fix the commit with an amend:
This will open your default text editor. Look for thegit commit --amendAuthor:andCommitter:lines, and add a space between your email's closing angle bracket and the date. For example:Author: Luca luca@example.com Thu Jan 18 14:30:00 2024 +0100
- If you just want to set the date to the current time instead of keeping the epoch placeholder, you can skip manual editing and run:
git commit --amend --date="$(date -R)" - After saving the changes, run
git fsckagain to confirm the error is gone.
2. If the bad commit is buried in your history
- Use interactive rebase to edit the problematic commit:
git rebase -i HEAD~3 # Replace 3 with how many commits back the bad one is - In the editor that pops up, find the line for commit
1e39456and changepicktoedit. Save and close the editor. - Git will pause at that bad commit. Now run the amend command to fix the date/author format:
git commit --amend --date="$(date -R)" - Continue the rebase process with:
git rebase --continue - Once done, run
git fsckto verify the issue is resolved.
3. Prevent this from happening again
- Before re-running the Git LFS migrate, double-check your Git user config is set correctly:
If either command returns nothing, set them with:git config user.name git config user.emailgit config --global user.name "Your Full Name" git config --global user.email "your.email@example.com" - If you had to reset the bad commit first (using
git reset --hard HEAD~1), re-run the migrate command:
This should generate a properly formatted commit this time around.git lfs migrate import --no-rewrite luca/models/weights/yolov5m.pt
内容的提问来源于stack exchange,提问作者Luca
相关产品推荐
相关产品推荐

