0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

git branch -vをしたらの'error: non-monotonic index .git/~~'というエラーが出た

Last updated at Posted at 2024-08-11

解決方法:

non-monotonic indexで報告されるファイルを削除してから、git gcをしたところ治った

経緯:

Nvim起動時、cder.vimの読み込みでエラーがでるなーと思ったらHDDの障害でフォルダが読み込めなくなっていた
それ自体はドライブのエラーチェックをしたら治ったけど、今度はcder.vimフォルダに入ってgit branch -vをするとこんなエラーが出るようになった

[⌚22:30:51.668]❯ git branch -v
error: non-monotonic index .git/objects/pack/pack-f8b0eee9aaef4afd78b71d965c20d911ee08dc39.idx
error: non-monotonic index .git/objects/pack/pack-f8b0eee9aaef4afd78b71d965c20d911ee08dc39.idx 
error: non-monotonic index .git/objects/pack/pack-f8b0eee9aaef4afd78b71d965c20d911ee08dc39.idx 
* support_windows 63c2d77 Support windows draft 1

ぐぐるとstackoverflowに同じ症例と直し方を発見、試すことにした
参考サイト:git extensions - Git error "non-monotonic index" - Stack Overflow

HDDが変なのか、コマンドラインから削除できない。エクスプローラーからはできた。その後もgit index-packもできない。けどgit gcはでき、これでgit branch -vもできるようになった。

[⌚22:31:00.545]❯ rm .git\objects\pack\pack-f8b0eee9aaef4afd78b71d965c20d911ee08dc39.idx       
Error: nu::shell::remove_not_possible

  × Remove not possible
   ╭─[entry #2:1:4]
 1 │ rm .git\objects\pack\pack-f8b0eee9aaef4afd78b71d965c20d911ee08dc39.idx
   ·    ─────────────────────────────────┬─────────────────────────────────
   ·                                     ╰── Could not delete D:\Users\masaaki\scoop\apps\nvim-data\lazy\cder.nvim\.git\objects\pack\pack-f8b0eee9aaef4afd78b71d965c20d911ee08dc39.idx: アクセスが拒否されました。 (os error 5)
   ╰────

(ここでエクスプローラーからファイルを削除した)

cder.nvim on  support_windows +0/-0 ✅ via 🌙 v5.4.2 
[⌚22:35:56.807]❯ git index-pack .git\objects\pack\pack-f8b0eee9aaef4afd78b71d965c20d911ee08dc39.pack
fatal: pack signature mismatch

cder.nvim on  support_windows +0/-0 ✅ via 🌙 v5.4.2 
[⌚22:38:35.027]❯ git gc
Enumerating objects: 87, done.
Counting objects: 100% (87/87), done.
Delta compression using up to 12 threads
Compressing objects: 100% (45/45), done.
Writing objects: 100% (87/87), done.
Total 87 (delta 0), reused 87 (delta 0), pack-reused 0 (from 0)
                                                                                                                               took 736ms 
cder.nvim on  support_windows +0/-0 ✅ via 🌙 v5.4.2 
[⌚22:40:57.111]❯ git branch -v
* support_windows 63c2d77 Support windows draft 1

解決してよかった!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?