• git添加远程仓库


    第1步:创建SSH Key。在用户主目录下,看看有没有.ssh目录,如果有,再看看这个目录下有没有id_rsaid_rsa.pub这两个文件,如果已经有了,可直接跳到下一步。如果没有,打开Shell(Windows下打开Git Bash),创建SSH Key:

    $ ssh-keygen -t rsa -C "youremail@example.com"
    把邮件地址换成你自己的github账号邮箱,然后一路回车,使用默认值即可

    第2步:登陆GitHub,按下图箭头进入SSH设置页面

    然后,点“New SSH Key”,填上任意Title,在Key文本框里粘贴id_rsa.pub文件的内容

    现在回到本地计算机,进入gitbash,链接远程github库

    首先测试ssh key是否成功

      使用命令:ssh -T git@github.com

      如果出现You’ve successfully authenticated, but GitHub does not provide shell access 。这就表示已成功连上github。

    测试成功后关联远程github库:

      $ git remote add origin git@github.com:michaelliao/learngit.git

      请将git@github.com:后改成如下图的git仓库的ssh地址

    若有如下报错:

    解决办法如下:

        1、先输入$ git remote rm origin

        2、再输入$ git remote add origin git@github.com:djqiang/gitdemo.git 就不会报错了!

        3、如果输入$ git remote rm origin 还是报错的话,error: Could not remove config section 'remote.origin'. 我们需要修改gitconfig文件的内容

        4、找到你的github的安装路径,我的是C:UsersASUSAppDataLocalGitHubPortableGit_ca477551eeb4aea0e4ae9fcd3358bd96720bb5c8etc

        5、找到一个名为gitconfig的文件,打开它把里面的[remote "origin"]那一行删掉就好了!

        

    初次把本地库的内容推送到远程:

    $ git push -u origin master

    后续把本地库的内容推送到远程:

    $ git push origin master


    SSH警告

    当你第一次使用Git的clone或者push命令连接GitHub时,会得到一个警告:

    The authenticity of host 'github.com (xx.xx.xx.xx)' can't be established.
    RSA key fingerprint is xx.xx.xx.xx.xx.
    Are you sure you want to continue connecting (yes/no)?
    

    这是因为Git使用SSH连接,而SSH连接在第一次验证GitHub服务器的Key时,需要你确认GitHub的Key的指纹信息是否真的来自GitHub的服务器,输入yes回车即可。

    Git会输出一个警告,告诉你已经把GitHub的Key添加到本机的一个信任列表里了:

    Warning: Permanently added 'github.com' (RSA) to the list of known hosts.
    

    这个警告只会出现一次,后面的操作就不会有任何警告了。

  • 相关阅读:
    Window 下配置ChromeDriver(简单4步完成)[转]
    selenium之 chromedriver与chrome版本映射表(更新至v2.46)[转]
    学习网站
    如何理解python中的类和方法(转)
    面试题整理20191127
    mysql 慢查询
    python学习--代码组织实例
    ubuntu下安装Matlab
    SkinPP for VC
    C++中的4个类型转换关键字
  • 原文地址:https://www.cnblogs.com/webwangjie/p/7285553.html
Copyright © 2020-2023  润新知