Git学习笔记

1. Git介绍
  a) 完整的版本控制功能,解决多人协作问题
  b) 提高开发效率
2. Git安装
  a) Git安装
    i. 下载并安装windows git
      - Msysgit(https://git-scm.com/download/win)
    ii. 配置用户信息
      - git config --global user.name “wayne”
      - git config --global user.email “zs577215@gmail.com”
  b) 客户端GUI安装
    i. 下载并安装sourceTree
      - https://www.sourcetreeapp.com
3. Git工作流
  a) 创建仓库
    i. 初始化版本库
      - git init
    ii. 添加文件到版本库
      - git add
      - git commit
    iii. 查看仓库状态
      - git status
    iv. GUI图示
      

    v. Command Line图示
      

  b) 工作流 (工作区 – 暂存区 – 版本库)
      


4. 远程仓库 (git remote add – git pull – git push – git clone)
  a) 创建SSH key
    i. ssh-keygen -t rsa -C “zs577215@gmail.com”
    ii. cd ~/.ssh
    iii. cat id_rsa.pub
    iv. 复制id_rsa.pub的内容到github的SSH keys中
  b) 添加远程仓库(command line)
    i. 在github新建仓库
    ii. 添加提交
      

  c) 添加远程仓库(GUI)
      

5. 克隆仓库
  a) 克隆远程仓库到本地 – command line
    clone git@github.com:wayne06 /clone_repo_demo.git
  b) 克隆远程仓库到本地 – GUI
    i. clone
    ii. push to orgin
6. 标签管理 – 通过标签回滚
  a) 查看所有标签
    i. git tag
  b) 创建标签
    i. git tag name
  c) 指定提交信息
    i. git tag -a name -m “comment”
  d) 删除标签
    i. git tag -d name
  e) 标签发布
    i. git push origin name
7. 分支管理 (git branch – git checkout – git merge)
  a) 创建分支
    i. git branch feature_x
  b) 查看分支
    i. git branch
  c) 切换分支
    i. git checkout feature_x
  d) 合并分支
    i. git merge feature_x
  e) 删除分支
    i. git branch -d feature_x

原文地址:https://www.cnblogs.com/wnzhong/p/10292330.html