Git常见报错处理
# 报错一:error object file is empty , The remote end hung up unexpectedly
关机重启后发现造成了 Git 数据异常,无法拉取代码。
# 1. 删除所有因为数据损坏导致的空对象文件
╰─ find .git/objects/ -type f -empty | xargs rm
1
# 2. 下载上一步删除的对象文件
╰─ git fetch -p
error: refs/heads/master does not point to a valid object!
error: refs/remotes/origin/HEAD does not point to a valid object!
error: refs/remotes/origin/master does not point to a valid object!
error: refs/heads/master does not point to a valid object!
error: refs/remotes/origin/HEAD does not point to a valid object!
error: refs/remotes/origin/master does not point to a valid object!
error: refs/heads/master does not point to a valid object!
error: refs/remotes/origin/HEAD does not point to a valid object!
error: refs/remotes/origin/master does not point to a valid object!
error: refs/heads/master does not point to a valid object!
error: refs/remotes/origin/HEAD does not point to a valid object!
error: refs/remotes/origin/master does not point to a valid object!
error: refs/heads/master does not point to a valid object!
error: refs/remotes/origin/HEAD does not point to a valid object!
error: refs/remotes/origin/master does not point to a valid object!
remote: Enumerating objects: 17663, done.
remote: Counting objects: 100% (16652/16652), done.
remote: Compressing objects: 100% (5823/5823), done.
remote: Total 16067 (delta 7404), reused 15218 (delta 6812), pack-reused 0
Receiving objects: 100% (16067/16067), 6.42 MiB | 952.00 KiB/s, done.
Resolving deltas: 100% (7404/7404), completed with 251 local objects.
......
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 3. 做一次全面的存储对象检查
╰─ git fsck --full
Checking object directories: 100% (256/256), done.
Checking objects: 100% (422267/422267), done.
dangling commit 2106d273955dc42d1b5ad7153ee911cee74aad14
dangling tree 2707c3be308ae0ffa1cf2dbbe1c62a041730eaa5
dangling blob 785dc689c4003a6a70e0c1888b1317014aa53d23
dangling commit fe7206b756bdba8cbb05a8ab20842f23fcb6aaf3
1
2
3
4
5
6
7
2
3
4
5
6
7
# 4. 重新Pull代码
╰─ git pull
remote: Enumerating objects: 99, done.
remote: Counting objects: 100% (99/99), done.
remote: Compressing objects: 100% (53/53), done.
remote: Total 69 (delta 18), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (69/69), 73.27 KiB | 1.13 MiB/s, done.
......
1
2
3
4
5
6
7
2
3
4
5
6
7
# 报错二:fatal: remote origin already exists
在上传本地代码到 Gitee 仓库时,出现下面报错信息: fatal: remote origin already exists.
。
# 先执行删除远程地址
git remote rm origin
# xxxxxx内容为远程项目地址
git remote add origin git@gitee.com:xxxxxx.git
1
2
3
4
5
2
3
4
5
上次更新: 2023/09/05, 16:08:13