description
I don’t know what’s going on. Recently, the following errors have appeared two or three times in a row, git pull
and they will appear every time . I searched the Internet. Similar problems are very common. Each has its own solution.
Error message:
error: object file .git/objects/40/bda4e3b79c3d7bf598df31d9e68470f97a3f79 is empty
fatal: loose object 40bda4e3b79c3d7bf598df31d9e68470f97a3f79 (stored in .git/objects/40/bda4e3b79c3d7bf598df31d9e68470f97a3f79) is corrupt
Solution
The solution here is mainly for the case of uncommitted code . The following commands are all used under ubuntu, and the main commands are different under win.
(1) Re-cloning method
This is on stackoverflow.com, and everyone likes it a lot.
Note : This method will lose your local unpush submissions and changes, as well as all stash, and you need to resubmit after processing. foo is the local version library.
cp -R foo foo-backup
git clone [email protected]:foo foo-newclone
rm -rf foo/.git
mv foo-newclone/.git foo
rm -rf foo-newclone
(2) reflog method (not verified)
I haven’t tried this method for the time being, I hope it works.
rm .git/objects/40/bda4e3b79c3d7bf598df31d9e68470f97a3f79
git fsck --full
git reflog
(3) Fetch method (not verified)
Special note : This is similar to the first method above, but the domestic document is much larger and the local version library is backed up by one step, causing the loss of your unpushed work.
cp -R foo foo-backup
rm -fr .git
git init
git remote add origin [your-git-remote-url]
git fetch
git reset --mixed origin/master
git branch --set-upstream-to=origin/master master
Similar Posts:
- error: src refspec master does not match any [How to Solve]
- Git Unable to switch remote branches error: pathspec ‘origin/XXXX’ did not match any file(s) known to git
- Git | fatal: refusing to merge unrelated histories [How to Solve]
- [Solved] Git pull fatal: refusing to merge unrelated histories
- Git – Your branch and ‘origin/xxx’ have diverged
- Git Error: nothing to commit, working directory clean [How to Solve]
- [Solved] brew update Error: “fatal: Could not resolve HEAD to a revision”
- Git Pull Error: Please specify which branch you want to merge with.
- Git error: requested URL returned error: 403
- Git Push hint: Updates were rejected because the remote contains work that you do hint: not have …