git 使用三剑客

  • git 使用三剑客
    • git
      • why use git
      • how use git
    • gitflow
      • why use git flow
      • how use git flow
    • sourcetree
      • why use sourcetree
      • how use sourcetree

git

Git 是 分布式版本管理系统。最初由林纳斯·托瓦兹创作,于 2005 年以 GPL 发布。最初目的是为更好地管理 Linux 内核开发而设计。

背景:2005 年,安德鲁·垂鸠写了一个简单程序,可以连接 BitKeeper 的存储库,BitKeeper 著作权拥有者拉里·麦沃伊认为安德鲁·垂鸠对 BitKeeper 内部使用的协议进行逆向工程,决定收回无偿使用 BitKeeper 的许可。Linux 内核开发团队与 BitMover 公司进行磋商,但无法解决他们之间的歧见。林纳斯·托瓦兹决定自行开发版本控制系统替代 BitKeeper,以十天的时间,编写出第一个 git 版本

why use git

  • 分布式--方便
  1. 去中心化

没有中心服务器的,每个人机器上都是一个完整的库

  1. 本地提交

a、 断网提交
b、小步提交。可以对自己的阶段成果有跟踪,并且提高每次变更的安全性
c、本地库。这个和断网提交是同一个实现,但从需求角度出发则略有不同,主要是说即使只有自己一个人开发项目,也可以轻易的让自己的代码有版本跟踪,而不需要去费力建个什么svn server
d、本地回滚。这个其实是由于本地库的存在而产生的,但可以减少中央库上的冗余版本

  • 数据存储 --快速
git 使用三剑客_第1张图片
image.png
  • tree
  • blob
  • commit

每次commit 只记录文件的变化

how use git

git-scm.com/docs 查看官网是了解和使用 git 的最好方式

使用步骤

  • 提交到本地版本库
  # git branch feature/auth
  # 查看文件状态
  git status
  # 添加本地缓存
  git add .
  # 提交到本地服务器
  git commit -m "feat:第三方登录"
  • 拉取最近代码
  # 切换到develop分支
  git checkout develop
  # 抓取并合并至当前分支
  git pull
  • 将远程库与本地代码合并结果提交到本地版本库
    # 合并
    git merge feature/auth
    # 删除
    git branch -d feature/auth
  • 将本地版本库推到服务器
    # 合并
    git push

gitflow

  • git 的使用规范

Gitflow 是一个 Git 工作流程设计 Workflow,The Gitflow Workflow defines a strict branching model designed around the project release. This provides a robust framework for managing larger projects. first published and made popular by Vincent Driessen at nvie.

  • git 的插件扩展

    github.com/nvie/gitflow

Git extensions to provide high-level repository operations for Vincent Driessen's branching model.

why use git flow

科学技术是第一生产力

how use git flow

git flow init
git flow feature
git flow bugfix
git flow release
git flow hotfix
git flow support
git flow version
git flow config

  • git flow init

初始化

  • git flow config

查看 flow 规范

  • git flow feature
# 开启一个开发分支, 从develop
git flow feature start
# 发布一个分支
git flow feature publish
# 结束一个分支,合并到develop
git flow feature finish
git flow feature [list]
or: git flow feature start
or: git flow feature finish
or: git flow feature publish
# 跟踪
or: git flow feature track
or: git flow feature diff
or: git flow feature rebase
or: git flow feature checkout
or: git flow feature pull
or: git flow feature delete
  • git flow bugfix
# 开启一个bug分支,从develop
git flow bugfix start
# 结束一个分支,合并到develop
git flow bugfix finish
  • git flow hotfix
# 开启一个bug分支,从master
git flow hotfix start
# 结束一个分支,合并到master,develop
git flow hotfix finish

sourcetree

Free,Simplicity and power in a beautiful Git GUI,免费,简洁和强大的一个美丽的Git GUI

why use sourcetree

科学技术是第一生产力

how use sourcetree

拿来主义:
www.jianshu.com/p/5be78fd1b0cb

你可能感兴趣的:(git 使用三剑客)