Skip to main content

4.Git相关 报错汇总

報錯:Failed to load config stat /etc/gitlab-runner/config.toml: no such file or directory builds=0 max_b

背景: 安裝gitlab-runner后docker log顯示該報錯

解決方案: 这个问题不必担心,当我们将gitlab-runner注册到Gitlab时,会自动生成该文件;

參考鏈接: https://www.php.cn/faq/480699.html

https://stackoverflow.com/questions/68830713/gitlab-where-is-config-toml

報錯: Git : fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists

背景:彈出 git@gitxxxxx 提示輸入密碼但是無論輸入什麽密碼都報錯。

解決方案1: 使用gitlab時遇到的報錯,網上的大多數方法都是在gitlab上添加ssh key,我試過了沒有效果,從後臺看出,添加的ssh key也沒有使用記錄,不過還是記錄下解決方法:

#1.在自己電腦上生成SSH KEY
ssk-keygen -t rsa -C "gitlab關聯的郵箱"
#將公鑰 id_rsa.pub 的内容黏貼到 gitlab的 ssh密鑰區域
#公鑰位置:
#windows:C:\Users\xxxx\.ssh\id_rsa.pub
#linux: /home/xxx/.ssh/id_rsa.pub

解決方案2: 此方法解決了我的問題,具體是先清除已有的git remote遠程鏈接,再使用http的方式重新添加遠程鏈接:

#先刪除原先的遠程鏈接
git remote remove origin
#再使用http的方式添加遠程鏈接
git remote add origin http://gitlab.xxxxx.com/halo/halo-theme-dream2.0.git

解决方案3: gitlab的gitlab.yml中的host参数设置有问题,gitlab web端访问端口是88,但是yml文件是80,改成88后能够正常使用了

不过可能不是这个问题导致的,因为在操作过程中,我使用上面方法2操作了一遍。

  gitlab:
## Web server settings (note: host is the FQDN, do not include http://)
host: 192.168.123.130
port: 88
https: false

参考:https://stackoverflow.com/questions/30068298/git-fatal-could-not-read-from-remote-repository-please-make-sure-you-have-th

報錯:error: Your local changes to the following files would be overwritten by merge: wp-content/w3tc-config/master.php Please, commit your changes or stash them before you can merge.

背景:使用git revert回退版本時報錯,類似如上

解決方案1: 以上報錯意思是需要先commit或stash本地倉庫,然後才能revert。例如:

#可以使用commit,然後revert
git commit -m "My message"
git revert "commit_hash"

#也可以先取消本地變更
git stash save "message"
git revert "commit_hash"

参考:https://stackoverflow.com/questions/15745045/how-do-i-resolve-git-saying-commit-your-changes-or-stash-them-before-you-can-me

报错:push推送报错: Updates were rejected because the remote contains work that you do not have locally. This is usually caused by another repository pushing to the same ref. You may want to first integrate the remote changes

解決方案: 本地repo中不包含遠程repo的部分内容,需要先pull拉取内容,然後在push合并

git pull origin master
git push origin master

参考:https://stackoverflow.com/questions/24357108/error-updates-were-rejected-because-the-remote-contains-work-that-you-do-not-ha

報錯:gitlab-rake "gitlab:password:reset" 更改密碼提示成功,但是使用新密碼無法登錄

解決方案: 更改了多次,最後使用含有大小寫,特殊符號的12位密碼更改成功了

報錯:try increasing http.postBuffer\nerror: RPC failed

解決方案:更改git緩衝區大小。改完緩衝區后一點要重新push,不然不生效

#緩衝區更改成500M大小
git config http.postBuffer 524288000
#
git push

參考: https://www.jianshu.com/p/b324a1f1383a

報錯:Error: connect ECONNREFUSED /run/user/1000/vscode-git-59d70845d7.sock

背景:使用vscode連接遠程服務器,git push到遠程倉庫時報錯

解決方案:重啓vscode編輯器,然後重新push

參考:https://stackoverflow.com/questions/65090102/why-im-getting-error-connect-enoent-from-vscode-on-git-push-origin

https://stackoverflow.com/questions/61730851/git-clone-i-get-a-strange-authentication-error