remove .git/index? yes

【エラー対応git】fatal: index file smaller than expected

もしgitやsourceTreeでfatal: index file smaller than expectedが出たら

こちら と同じ症状。コミットもプッシュもブランチ切り替えもできなくなる

原因 .git/indexのファイルが破損している。自分の場合はWP内でリポジトリルートフォルダパスを変えたらおかしくなったと思う

参照記事 ・https://vertis.io/2012/01/24/git-fatal-index-file-smaller-than-expected.html ・https://jira.atlassian.com/browse/SRCTREE-2018

解決処理 1、そのレポジトリのバックアップ取っておく 2、コマンドで.gitカレントに移動して下記を実行 rm .git/index (rmで確認をオプションで付けていると聞いてくるからyesと打つ)

remove .git/index? yes
]2 remove .git/index? yes

git add .

3、解決したらお腹減ったと思うので休憩する