Git: «Corrupt loose object»

После аварийного завершения работы компьютера git выдал

$ git status
error: object file .git/objects/03/9e5691db59686e2afce2da700853398c961b4a is empty
error: object file .git/objects/03/9e5691db59686e2afce2da700853398c961b4a is empty
fatal: loose object 039e5691db59686e2afce2da700853398c961b4a (stored in .git/objects/03/9e5691db59686e2afce2da700853398c961b4a) is corrupt

Всё синхронизировано с удалённым git-репозиторием, поэтому особо не стал озадачиваться проблемой…

$ rm -rf .git
$ git init
$ git remote add origin адрес_репозитория
$ git fetch
$ git reset --hard origin/master

Частые push и коммиты небольших изменений (но, естественно, логически отдельных) — это прекрасно, но, интересно, а что делать в этой ситуации, если жалко терять изменения? git fsck ? fsck ?

Git (no branch)

Sometimes you can get a weird situation:

$ git branch
 * (no branch)
 master

But you can back in a master branch (or some other branch) and save all changes.

Get commit’s hash from git log.

$ git log
 commit d735ee31656010d25765f395d98cbbdbe5b448e8 <---- It's here!
 Author: Georgy Bazhukov <gosha@bugov.net>
 Date:   Wed May 29 13:05:15 2013 +0600

    more code!

And change branch

$ git checkout master

After you should merge a current commit (HEAD) with commit from «(no branch)»

$ git merge d735ee31656010d25765f395d98cbbdbe5b448e8

«Towel day». Achievement unlocked!

Many companies uses Jira+Stash (issue tracker+git) for code development. And it’s pretty handy. Also you can install plug-in for achievements (for free). And it’s fun!

For example new developers starts to use issues in git-comments to get achievement «BugHunter». After that they still use issues in comments because it’s a good practice and they are used.

achievment

But some of achievements are anti-achievements. For example «Pardon my French» (swearing in comments).

Once per year you can unlock achievement «Towel day». But I missed it this year. «Don’t panic!» — you can get it any time :)

git commit --amend --date="Sat May 25 14:00 2013 +0600"

Yes, it’s a cheat in a developer’s tool. But who blames me? Achievements are so delicious! ^_^

Ошибка при git pull: HTTP code = 411

$ git push origin master
 Password for 'https://bugov@www.***.ru':
 Counting objects: 1243, done.
 Delta compression using up to 4 threads.
 Compressing objects: 100% (1126/1126), done.
 error: RPC failed; result=22, HTTP code = 411
 fatal: The remote end hung up unexpectedly
 Writing objects: 100% (1243/1243), 4.32 MiB | 1.97 MiB/s, done.
 Total 1243 (delta 310), reused 0 (delta 0)
 fatal: The remote end hung up unexpectedly
 Everything up-to-date

Решение:

git config http.postBuffer 524288000 # 500Mb