GitHub使用(ing。。。)

git官方文档 pro git

GitHub初始配置

  1. 设置git试用的姓名和邮箱地址。

    git config --global user.name "dongdong wu"
    git config --global user.email "745661590@qq.com"
    cat .gitconfig 
    //会显示
    [user]
    name = dongdong wu
    email = 745661590@qq.com
    
  2. 提高代码可读性(暂时没体验到用处)

        git config --global color.ui auto
        cat .gitconfig 
        //会显示
        [color]
         ui = auto
  3. 创建GitHub用户

    • 就可以得到公开界面的URL:https://github.com/Thor-jelly
    • 设置一个头像
    • 设置SSH Key 官网介绍地址

      • 创建SSH Key
          ssh-keygen -t rsa -C "745661590@qq.com" 
          Generating public/private rsa key pair.
          //输入文件名称,可以直接回车键
          Enter file in which to save the key (/Users/shandian/.ssh/id_rsa): 
          Created directory '/Users/shandian/.ssh'.
          //输入密码
          Enter passphrase (empty for no passphrase): 
          //再次输入密码
          Enter same passphrase again: 
          Your identification has been saved in /Users/shandian/.ssh/id_rsa.
          Your public key has been saved in /Users/shandian/.ssh/id_rsa.pub.
          The key fingerprint is:
          //会得到--fingerprint值 和 你输的邮箱
          fingerprint值 745661590@qq.com
          The key's randomart image is:
          +---[RSA 2048]----+
          |                 |
          |                 |

      这样就会创建了SSH Key,其中id_rsa是私有秘钥,id_rsa.pub是公开秘钥
      查看公共秘钥中的内容

          cat ~/.ssh/id_rsa.pub
          //会得到
          公开秘钥内容 745661590@qq.com
      • 添加公开秘钥

        • 进入设置界面–>https://github.com/settings/keys
        • 点击 new ssh key 按钮进行添加key,设置key 名称和key。
          秘钥方法
          如果添加成功了,你就会收到一份邮件:公共秘钥添加成功
        • 完成上述设置后,就可以用私人秘钥与GitHub进行认证和通信了。

          ssh -T git@github.com
          The authenticity of host 'github.com (192.30.255.112)' can't be established.
          RSA key fingerprint is `fingerprint值`
          Are you sure you want to continue connecting (yes/no)? //输入yes
          Warning: Permanently added 'github.com,192.30.255.112' (RSA) to the list of known hosts.
          Enter passphrase for key '/Users/shandian/.ssh/id_rsa': //输入密码
          //出现下面提示表明成功
          Hi Thor-jelly! You've successfully authenticated, but GitHub does not provide shell access.

仓库

  1. 创建–》点击工具栏-new repository
    这里写图片描述
    全部填写好,点击create repository

  2. 复制项目URL:git@github.com:Thor-jelly/Test.git

    在git中clone项目有两种方式:HTTPS和SSH,它们的区别如下:

    • HTTPS:不管是谁,拿到url随便clone,但是在push的时候需要验证用户名和密码;
    • SSH:clone的项目你必须是拥有者或者管理员,而且需要在clone前添加SSH Key。
    • SSH 在push的时候,是不需要输入用户名的,如果配置SSH key的时候设置了密码,则需要输入密码的,否则直接是不需要输入密码的。
  3. clone项目

    git clone git@github.com:Thor-jelly/Test.git
    Cloning into 'Test'...
    remote: Counting objects: 4, done.
    remote: Compressing objects: 100% (3/3), done.
    remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0
    Receiving objects: 100% (4/4), done.
  4. 更改README文件内容

    
    # Test
    
        测试使用GitHub
    
    
    ## 我的第一次提交到GitHub
    
  5. 提交代码

    • 先查看当前状态
      git status
    • 提交

      git add 当前文件名                    //把文件添加到暂存区
      git commit -m "first commit"  //再通过改命令进行提交
    • 查看提交日志

      git log
    • 提交到仓库

      git push
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值