gitLab&github的一些问题处理

概述

github以及gitlab是大部分开发者都在使用的仓库管理工具。笔者在使用的过程中收集了一些之前遇到的问题,并撰写了该文章,以后有更新的会不定期在文章后添加。

git clone无权限

拉取公司项目的仓库,发现拉取失败:

git clone [email protected]:ios/Evian.git
Cloning into 'Evian'...
[email protected]: 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 [email protected]
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://[email protected]/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://[email protected]/derekerdmann/lunch_call.git to url=ssh://[email protected]/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

广告

我的首款个人开发的APP壁纸宝贝上线了,欢迎大家下载。

壁纸宝贝

你可能感兴趣的:(gitLab&github的一些问题处理)