一个git问题的处理

文章目录

表现

git clone 报错 ;

最后在chatgpt的帮助下艰难修复了。

起因:

周一凌晨3点多gitea报错,

周一上班之后git推送很慢。

然后后重启NAS;再然后就出现了不能clone的现象

环境

群晖 + docker + gitea(1.26.1)

流程

先找到 Gitea 容器

在群晖 SSH 中执行:

sh 复制代码
sudo docker ps | grep -i gitea

应该能看到类似:

log 复制代码
abc123456789   gitea/gitea:...   ...   gitea

最后一列通常就是容器名。

然后进入容器:

bash 复制代码
sudo docker exec -it gitea /bin/bash

进入之后执行

sh 复制代码
ls -ld /data/git

Gitea 版本

sh 复制代码
gitea --version
html 复制代码
gitea version 1.26.1 built with go1.26.2-X:jsonv2 : bindata, timetzdata, sqlite, sqlite_unlock_notify

sourcetree中报

log 复制代码
git -c diff.mnemonicprefix=false -c core.quotepath=false --no-optional-locks fetch --prune --no-tags origin fatal: cannot exec '/data/git/repositories/XXXX/YYYYY.git/hooks/pre-applypatch.sample': No such file or directory fatal: git upload-pack: unable to fork git-pack-objects error: error: Failed to execute git command error: fetch-pack: unexpected disconnect while reading sideband packet fatal: protocol error: bad pack header
复制代码
/data/git/repositories/BayerGit/UI_Remake_drilling.git/hooks/pre-applypatch.sample

然后我经历了重建库、重新上传代码、拉取还是失败、

最后找到了

/data/gitea/home/.gitconfig

有问题:

vim 复制代码
[core]
        logallrefupdates = true
        quotePath = false
        commitGraph = true
[gc]
        reflogexpire = 90
        writeCommitGraph = true
[diff]
        algorithm = histogram
[user]
        name = Gitea
        email = gitea@fake.local
[receive]
        advertisePushOptions = true
        procReceiveRefs = refs/for
[fetch]
        writeCommitGraph = true
[safe]
        directory = *
[uploadpack]
        allowfilter = true
        allowAnySHA1InWant = true

[uploadpack]
        packObjectsHook = /data/git/repositories/XXXX/YYYYYY.git/hooks/pre-applypatch.sample
# router: completed POST /api/internal/manager/add-logger for 172.18.0.1:46466, 200 OK in 0.5ms @ private/manager.go:104(private.AddLogger)

[uploadpack]
        packObjectsHook = /data/git/repositories/XXXX/YYYYYY.git/hooks/pre-applypatch.sample
# router: completed GET /api/internal/serv/command/5/BayerGit/UI_Remake_drilling?mode=1&verb=git-upload-pack for 172.18.0.1:0, 200 OK in 1.4ms @ private/serv.go:79(private.ServCommand)

我把 packObjectsHook = 这两行删掉就好了

后来我又问了豆包,豆包让后把那一行改成

sh 复制代码
[pack]
    packObjectsHook = /usr/local/bin/gitea serv pack-objects-hook

我没改。问题到这里已经解决了,就不改了。

总结

就这样吧,花了半天时间。

你猜我开不开心~

相关推荐
互联网中的一颗神经元4 小时前
21 — 额外命令:同时开两个窗口、自动检查哨
git
_道隐_7 小时前
git stash save 和 git stash push有什么区别?
git
_道隐_9 小时前
git stash如何pop指定的stash change?
git
PC2005-cloud11 小时前
Git学习笔记:GitHub Git Data API 完全指南,用 Go 操控 Git 底层对象
笔记·git·学习
Python私教1 天前
AI 并行编码的 Worktree 生命周期:创建、隔离与安全回收
人工智能·git
互联网中的一颗神经元1 天前
16 — 改写历史 rebase:搬家到新楼层,不是合并
git
互联网中的一颗神经元1 天前
19 — 贮藏与清理:stash 是抽屉,gc 是打包箱
git
用户330144867631 天前
20 — 远程进阶:强制推送的保险绳——force-with-lease
git
Cooper251 天前
别急着改 Git 历史:rebase、cherry-pick、bisect 与 reflog 的安全操作顺序
git