Git User Guide

Git 用户指引

常用命令

命令 作用
git log --oneline --graph 查看 git 历史
git branch -a 列出所有远程本地分支
git fetch 更新远程仓库代码,checkout 新的远程分支前需要执行。
git checkout -b <分支名> origin/<分支名> Checkout 远程分支
git checkout -t origin/<分支名>  
get rebase [<远程别名>/]<分支名> 同步指定分支更新到当前分支
git reset --hard <Commit ID> 回滚到指定提交
git reset --hard HEAD 回滚到当前分支最终提交
git reset --hard origin/<分支名> 回滚到远程分支最终提交
git stash save -u 'STASH_NAME' 暂存当前工作区

本地库维护

git gc --aggressive --prune=now 回收无用缓存
   

SourceTree

Stash

使用 Stash 暂存本地变更后,展开左侧 Stashes 菜单,右键点击相应 stash 进行恢复。

Paging
Next
Prev

Git Flow

安装

# macOS
$ brew install git-flow-avh
$ brew install bash-git-prompt zsh-git-prompt

初始化 

$ git flow init -f # git flow init -d

Which branch should be used for bringing forth production releases?
   - 7.x
   - develop
Branch name for production releases: [7.x]

Which branch should be used for integration of the "next release"?
   - develop
Branch name for "next release" development: [develop]

How to name your supporting branch prefixes?
Feature branches? [feature/] feature/
Bugfix branches? [bugfix/] bugfix/
Release branches? [release] release/
Hotfix branches? [hotfix] hotfix/
Support branches? [support] support/
Version tag prefix? []

参考 

Author: njun
njun's picture
Updated: 2019/08/21