gitHub 基本操作

作者: zlf_j | 来源:发表于2018-05-16 17:03 被阅读28次

    一、 关联本地库和远程库:

    1. C盘 windows 打开Git Bash
    • git config --global user.name '你自己的用户名'
    • git config --global user.email '你自己的邮箱'
    2. 创建SSH Key
    • ssh-keygen -t rsa -C "你的邮箱地址" 文件名
    • 确认密码...
    • 复制 C盘 -> user -> Administrator -> .ssh文件夹 -> id_rsa_pub 中的内容
      (id_rsa_pub文件路径不固定)
    • 注意:

    mac找不到.ssh文件夹时,在git中执行 open ~/.ssh 回车,即可看到.ssh文件夹

    3. 添加秘钥
    • 登录GitHub, 点个人图标
    • 打开“Account settings”,
    • "SSH Keys”页面:然后,点“Add SSH Key”, 填入任意Title,在Key文本框里粘贴id_rsa.pub文件的内容
    4. 执行:
    • 新建文件夹(含html文件) 打开Git Bash
      git init 出现 .git文件 // 取消 rm -rf .git
      git status 红色 工作区
      git add .
      git status 绿色 暂存区
    • GitHub 新建文件
      git commit -m 'add new file' 提交到版本库
      git status 没东西
      复制GitHub中的
      git remote add origin 自己项目地址
      git push -u origin master
      执行

    二、 克隆别人的项目:

    • 新建文件夹 打开 Git Bash
    • git clone 对方的地址

    参考:https://www.cnblogs.com/jf-67/p/6415637.html

    三、 github本地修改后如何上传

    • git pull // 拉取代码
      git status // 查看文件状态
      git add .(提交所有文件) / 文件路径
      git commit -m '提交注释'
      git push
    • 注意:

    第一次创建repository后,修改文件想要提交,发现commit changes为灰色。
    初步分析是24小时后才能提交

    具体过程可参考:
    https://note.youdao.com/share/?id=178db978be603399f7b40fdcc21edebf&type=note#/
    github用法参考:
    https://guides.github.com/activities/hello-world/

    相关文章

      网友评论

        本文标题:gitHub 基本操作

        本文链接:https://www.haomeiwen.com/subject/gofmdftx.html