Git add . Gives me Bus error (core dumped)

走远了吗. 提交于 2021-02-18 22:08:42

问题


I am using ubuntu and trying to put my code on github but when I tried using the "git add ." command , I got an error "Bus error (core dumped)".

joannah@joannah-Inspiron-N5040:~/Macerdo$ git init
Initialized empty Git repository in /home/joannah/Macerdo/.git/
joannah@joannah-Inspiron-N5040:~/Macerdo$ git add .
Bus error (core dumped)
joannah@joannah-Inspiron-N5040:~/Macerdo$ 

I will appreciate any help.


回答1:


For future reference .I solved this by creating a new folder and putting all my project files there and when I did a "git add ." and "git commit" it worked but I still do not know why the former failed to work. The good thing is at least I got a solution and moved on. That is most important. Thanks for the contributions.




回答2:


This is how I solved this problem, assuming you can still run git diff:

  1. Generate a diff patch
  2. Remove repo
  3. Clone repo again
  4. Apply patch

git diff --patch > /tmp/patch.diff
cd ..
rm -rf my_repo
git clone <my_repo>
cd my_repo
patch -p1 /tmp/patch.diff



回答3:


Have a look at dmesg. In my case this was due to a hardware error: A bad sector on my disk. :(

This might explain why the command worked after copying the files.

You should find something like this:

[ 1387.312569] ata3.00: exception Emask 0x0 SAct 0x800 SErr 0x0 action 0x0
[ 1387.314589] ata3.00: irq_stat 0x40000008
[ 1387.316618] ata3.00: failed command: READ FPDMA QUEUED
[ 1387.318638] ata3.00: cmd 60/08:58:48:1e:54/00:00:12:00:00/40 tag 11 ncq 4096 in
                        res 41/40:00:4b:1e:54/00:00:12:00:00/40 Emask 0x409 (media error) <F>
[ 1387.322675] ata3.00: status: { DRDY ERR }
[ 1387.324690] ata3.00: error: { UNC }
[ 1387.363352] ata3.00: configured for UDMA/133
[ 1387.363369] sd 2:0:0:0: [sda] tag#11 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE
[ 1387.363375] sd 2:0:0:0: [sda] tag#11 Sense Key : Medium Error [current] [descriptor]
[ 1387.363379] sd 2:0:0:0: [sda] tag#11 Add. Sense: Unrecovered read error - auto reallocate failed
[ 1387.363384] sd 2:0:0:0: [sda] tag#11 CDB: Read(10) 28 00 12 54 1e 48 00 00 08 00
[ 1387.363388] blk_update_request: I/O error, dev sda, sector 307502667
[ 1387.365427] ata3: EH complete



回答4:


This happens to me quite often since my git repo is mounted via nfs, seems it times out and this causes a bus error sometimes.

The solution I found is to simply remove the lock files and continue on my merry way.

find .git -iname *.lock | xargs rm



回答5:


In my case, a .py file had been corrupted and I got this message every time I tried to add it to a commit.

Deleting the .git / index.lock replaces the damaged file and everything is back to normal.



来源:https://stackoverflow.com/questions/26627303/git-add-gives-me-bus-error-core-dumped

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!