• git 常用命令总结


    git是什么就不用说了,全世界都在用git。这里仅仅纪录git在mac上的一些使用命令(终端输入)操作,作为自己的备忘录,这里不做教程,下面会附上峰哥的教程。

     

    1.安装git

    最简单的安装方法,就是直接从AppStore安装Xcode,Xcode集成了Git,无需安装。

    然后,在命令窗口输入 git就可看到git信息。

     

    2.命令:

    初始化版本库: git  init

    添加命令:  git  add <your file name> 可反复多次添加

    提交命令:  git  commit -m”说明文字" 

    查看状态:  git status

    对比不同:  git  diff

    查看提交历史:  git  log

    查看命令历史:  git  reflog

    回退上个版本:  git  reset  --hard  HEAD

    回退指定版本:  git reset   --hard  版本id

    丢弃工作区修改: git checkout -- <your file name>  

    丢弃暂存区文件:    git reset 版本回退即可

    删除文件:  git  rm  并且  git  commit 

     

    查看分支:git  branch

    新建分支:git  branch  branch-name

    切换分支:git  checkout  branch-name

    创建+切换: git  checkout -b  branch-name

    合并分支(fast forward模式): git  merge  branch-name

         (禁用fast forward)  git merge --no-ff -m”提交说明” branch-name

    删除分支:git branch -d  branch-name

     

    隐藏工作区:git  stash

    查看隐藏列表: git stash list

    恢复隐藏区: git  stash  apply 

    删除隐藏曲: git  stash  drop

    恢复并删除: git  stash  pop

     

    查看标签: git  tag

    创建标签: git  tag  <name>   版本id(可选)

    删除标签: git  tag -d 版本号

     

    配置别名: git  config —global alias.yourcommand command

     

    创建 SSH-Key: ssh-keygen -t rsa -C "youremail@example.com”

    id_rsa: 私钥

    id_rsa.pub:公钥 

     

     

    把本地仓库和 远程Github 关联: git remote add origin  地址

    关联后第一次推送(默认分支):git push -u origin master 

    此后推送: 可省略参数 u

     

     

    从远程克隆仓库到本地:git clone 地址

     

    3.教程链接:

    http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000

     

     

     

  • 相关阅读:
    C++ sort排序
    ROS1 Qt5 CMake基本配置
    TCP连接connect函数返回错误
    自定义类型与Qt元对象系统
    Vue学习二、基本语法
    TypeScript学习: 十二、TS中的装饰器
    Vue学习四、使用双向数据绑定实现表单操作
    TypeScript学习: 十一、TS中的命名空间
    Vue学习三、事件方法、监听、传值
    TypeScript学习: 十、TypeScript的模块
  • 原文地址:https://www.cnblogs.com/donglegend/p/4728220.html
Copyright © 2020-2023  润新知