- Git - Git Flow - Recommendation

	--system #系统级别
	--global #用户全局
	--local #单独一个项目
	git config --global user.name "xxxx" #用户名
	git config --global user.email "xxxx@xxx.com" #邮箱
	git config --global core.editor vim #编辑器

	git config --global alias.st status #按这种方法,配置别名
	git config -l #列举所有配置
					

	- git init
	- git clone <url> [path]
	- git pull <remote> <branch>
	- git add
	- git push <remote> <branch>
				
Status - Untracked or Modified - Stage - Commit(Clean)
Diff

	- git diff
	- git diff <file> #比较工作区与暂存区文件的差异
	- git diff --cached   # 比较暂存区和版本库差异
	- git diff $id1 $id2   # 比较两次提交之间的差异
	- git diff branch1 branch2 # 在两个分支之间比较
					
Branch
Git Flow - 主要分支 - 支持性分支
主要分支 - master - develop ![](assets/git-branch-3.png)
支持性分支 - 特性分支(feature branch) - 发布分支(release branch) - 热补丁分支(hotfix branch)
特性分支 - 可能的分支来源:develop - 必须合并回:develop - 分支命名约定:feature/* ![](assets/git-branch-4.png)
发布分支 - 可能的分支来源:develop - 必须合并回:develop和master - 分支命名约定:release/*
热补丁分支 - 可能的分支来源:master - 必须合并回:develop和master - 分支命名约定:hotfix/* ![](assets/git-branch-6.png)
Recommendation - zsh - `git add .` - `git add -A` - `git commit` (without `-m`) - `git merge --no-ff` - `git rebase`

zsh

  • 上次运行命令状态
  • 是否为git目录
  • 当前分支
  • 修改状态
http://github.com/Treri/dotfile

	git clone http://github.com/Treri/dotfile ~/.dotfile
	cd ~/.dotfile
	./install.sh zsh_rc
					

git add .

git add -A

git commit (without -m)

commit log   ==>  commit summary

commit log <= 72 colums

`git merge --no-ff` (no fast forward) ![](assets/git-branch-5.png)

	# feature complete
	git checkout develop
	git pull origin develop
	git merge --no-ff feature/one
						
`git rebase`
工作状态 ![](assets/git-merge-1.jpg)
使用`git merge` ![](assets/git-merge-2.jpg)
使用`git rebase` ![](assets/git-merge-3.jpg) - Author - Commiter

	git commit # in local branch

	git checkout feature/one
	git pull origin feature/one
	git checkout feature/one_local
	git rebase feature/one
	git checkout feature/one
	git merge feature/one_local # without `--no-ff`
						
`git cherry-pick` 把一个分支的一个或多个commit修改应用到另一个分支 而不涉及其他commit
目标

1. 保持commit历史记录线性

2. 保持分支的产生和合并信息

## END