美文网首页
GIT学习笔记

GIT学习笔记

作者: hey白启明 | 来源:发表于2019-02-20 21:19 被阅读0次

    参考资料

    廖雪峰老师的GIT教程,以及runoob的GIT教程

    安装配置

    • Ubuntu/Linux使用sudo apt-get install git安装
    • WIndows在Git官网下载安装
    • 安装完成后要配置用户信息,使用$ git config --global user.name "Your Name"$ git config --global user.email "email@example.com"命令配置你的用户名和邮箱,否则无法提交。

    时光穿梭机

    命令 操作
    git init 创建仓库
    git add [filename] 提交文件到暂存区(stage)
    git commit -m "[message]" 提交文件到分支(master)
    git status 查看状态
    git diff 查看修改
    git reset --hard HEAD^ 退回上一版本
    git log 查看提交记录
    git reflog 查看提交历史记录
    git reset --hard [id] 退回指定版本
    git checkout -- file 丢弃工作区修改
    git reset HEAD [filename] 丢弃暂存区文件
    git rm [filename] 删除分支中的文件

    远程仓库

    • 创建你的SSHKEY ssh-keygen -t rsa -C "youremail@example.com"
    • 在远程仓库出创建仓库
    命令 操作
    git remote add origin git@github.com:[Uname]/[Rname].git 关联远程仓库
    git push -u origin master 关联并推送(首次使用)
    git push origin master 推送
    git pull origin master 取回远程仓库内容
    git clone git@github.com:[Uname]/[Rname].git 克隆远程仓库

    相关文章

      网友评论

          本文标题:GIT学习笔记

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