git与github的连接和使用(linux版)

git与github的连接和使用(linux版)

一 git的安装


  1. 安装git

    sudo apt-get install git
    

    git与github的连接和使用(linux版)

  2. git配置

    git config --global user.name "这里改为你的名字"
    git config --global user.email "这里改为你的邮箱地址"
    

    git与github的连接和使用(linux版)

  3. 创建公钥

    ssh-****** -C '这里改为你的邮箱地址' -t rsa
    

    git与github的连接和使用(linux版)

  4. 复制公钥内容

    • 进入~/.ssh文件夹
    cd ~/.ssh
    
    • 打开id_rsa.pub文件(deepin编辑器为dedit命令,ubuntu为gedit),复制内容.(此处若无法打开,则找到文件,用wps即可打开)
    dedit id_rsa.pub
    

    git与github的连接和使用(linux版)

二 github的连接

  1. 配置公钥

    git与github的连接和使用(linux版)

  2. 新建一个仓库

    git与github的连接和使用(linux版)

  3. 输入Repository name后,点击Create repository

    git与github的连接和使用(linux版)

  4. 在本地创建名为example的repository

    git init example
    cd example
    

    git与github的连接和使用(linux版)

  5. 编写README文件

    dedit README
    

    git与github的连接和使用(linux版)

  6. 依次执行以下命令

    git add README
    git commit -m "这里改为你自己想注释的内容"
    git remote add origin https://github.com/这里改为你自己的github名字/example.git
    git push origin master
    

    git与github的连接和使用(linux版)

  7. 大功告成!git与github的连接和使用(linux版)