gitLab&github的一些問題處理

概述

github以及gitlab是大部分開發(fā)者都在使用的倉庫管理工具。筆者在使用的過程中收集了一些之前遇到的問題,并撰寫了該文章,以后有更新的會不定期在文章后添加。

git clone無權限

拉取公司項目的倉庫,發(fā)現(xiàn)拉取失?。?/p>

git clone git@git.corp.xxx.cn:ios/Evian.git
Cloning into 'Evian'...
git@git.corp.imdada.cn: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

通過如下幾步解決該問題:
第一步:選中個人配置


第二步:選中SSH Keys,并輸入SSH Key


那么 SSH Key怎么生成呢,可以通過如下命令:

ssh-keygen

筆者的操作流程如下:

Generating public/private rsa key pair.
Enter file in which to save the key (/Users/kyson/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/kyson/.ssh/id_rsa.
Your public key has been saved in /Users/kyson/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:k/QfKoFlBR1tJiAnzd25kJPe2ES3soeUhGZOktQ41ow kyson@kysondeMacBook-Air.local
The key's randomart image is:
+---[RSA 2048]----+
|      o+=%oOo..  |
|       +E.^.Bo . |
|       .+O @+..  |
|       = o+.++   |
|      . S . + .  |
|         o o o   |
|        . . .    |
|         .       |
|                 |
+----[SHA256]-----+

git push無權限

remote: Permission to zjh171/GCDAsyncSocket.git denied to AngryLi.
fatal: unable to access 'https://github.com/zjh171/GCDAsyncSocket.git/': The requested URL returned error: 403

進入.git文件夾,找到config文件(.git文件夾是隱藏文件夾,位于當前項目的根目錄下):

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
    precomposeunicode = true
[remote "origin"]
    url = https://github.com/zjh171/GCDAsyncSocket.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master

中的

    url = https://github.com/zjh171/GCDAsyncSocket.git

修改為:

    url = https://zjh171@github.com/zjh171/GCDAsyncSocket.git

即可

Pushing to Git returning Error Code 403 fatal: HTTP request failed

Pushing to Git returning Error Code 403 fatal: HTTP request failed

解決方式:
Github seems only supports ssh way to read&write the repo, although https way also displayed 'Read&Write'.

So you need to change your repo config on your PC to ssh way:

  1. edit .git/config file under your repo directory
  2. find url=entry under section [remote "origin"]
  3. change it from url=https://MichaelDrogalis@github.com/derekerdmann/lunch_call.git to url=ssh://git@github.com/derekerdmann/lunch_call.git. that is, change all the texts before @ symbol to ssh://git
  4. Save config file and quit. now you could use git push origin master to sync your repo on GitHub

參考

Getting permission denied (public key) on gitlab

廣告

我的首款個人開發(fā)的APP壁紙寶貝上線了,歡迎大家下載。

壁紙寶貝

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

友情鏈接更多精彩內容