gitLab&github的一些问题处理

概述

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

git clone无权限

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

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

广告

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

壁纸宝贝

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容