Skip to content

Instantly share code, notes, and snippets.

@tiagojdf
Last active March 31, 2022 10:24
Show Gist options
  • Save tiagojdf/2f84a47033d0e7aaae42d93268a77578 to your computer and use it in GitHub Desktop.
Save tiagojdf/2f84a47033d0e7aaae42d93268a77578 to your computer and use it in GitHub Desktop.
# General clean up commands.
```
find . -type f -empty -delete
git fsck --full
git gc --aggressive --prune=now
```
# Dealing with bad ref head
```
tail .git/logs/HEAD # from http://git.661346.n2.nabble.com/corrupted-Git-repository-td6498902.html
git update-ref HEAD <hash> # from https://stackoverflow.com/questions/11706215/how-to-fix-git-error-object-file-is-empty
```
#For git file is empty loose object corrupt
https://stackoverflow.com/questions/4254389/git-corrupt-loose-object
```
find .git/objects/ -size 0 -exec rm -f {} \;
git fetch origin
```
# git pull fails 'error: refs/stash does not point to a valid object!'
https://stackoverflow.com/questions/20663239/git-pull-fails-error-refs-stash-does-not-point-to-a-valid-object
```
rm .git/refs/stash .git/logs/refs/stash
git stash
```
#When a rebase is stuck, go to a known point and:
https://stackoverflow.com/questions/55045740/stuck-in-a-git-rebase-how-to-reset
```
rm -rf .git/rebase-merge
```
If the problem is with stash
```
git stash clear
```
@tiagojdf
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment