Git 用户指引
安装
Debian/Ubuntu
sudo apt-get install software-properties-common gpg
sudo add-apt-repository ppa:git-core/ppa
常用信息
常用路径
常用设置
常用 Hook
.git/hooks/post-commit
Linux 下 post-commit 文件需要设置可执行权限。
#!/bin/sh
# 配合 commit 注释模版设置,留用最后一次 commit 注释的标题
printf "`git log -1 --pretty=%s`" > .git/COMMIT_TPL
#!/bin/sh
# 配合 commit 注释模版设置,留用最后一次 commit 的注释
printf "`git log -1 --pretty=%B`" > .git/COMMIT_TPL
常用命令
重置
注释
本地库维护
子模块
# 切换子模块 branch 拉取最新代码
git submodule sync
git submodule update --init --remote
发布
SourceTree
Stash
使用 Stash 暂存本地变更后,展开左侧 Stashes 菜单,右键点击相应 stash 进行恢复。
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? []