- 项目中有两个固定分支master和development
- 开发本地只克隆development分支, 只有需要relase或者hotfix时候才会在本地克隆master代码来进行合并
- 所有开发时新添加的feature或者新修复的bug都只能直接合并到development分支上
git clone -b development <remote-repository-name>
开始实现一个feature或者解决一个bug之前,首先切换到development分支上
git checkout development
创建feature或者bug的分支,并且切换到该分支
git checkout -b <feature-branch-name> development
修改一些文件,添加修改的文件到暂存区(staging area)
git add .
将修改后的文件提交到本地的版本库中
git commit -am 'Add a new feature'
提交之前保证你本地的development分支的代码是最新的
git checkout development
git pull origin development
将你在branch上完成的代码修改合并到development分支上
git merge <feature-branch-name>
or
git rebase -i <feature-branch-name>
提交代码到中央版本库
git push
*删除本地创建的分支(可选)
git branch -d <feature-branch-name>
git clone -recursive git://github.com/nvie/gitflow.git
下载完成后分别将两个压缩包解压文件下bin目录中的getopt.exe,libintl3.dll和libiconv2.dll文件拷贝到msysgit安装目录下的bin目录中
打开cmd命令行,进入已经克隆好的gitflow contrib目录中执行命令
D:\gitflow contrib>msysgit-install.cmd "C:\Program Files\Git".
usage: git flow <subcommand>
Available subcommands are:
init Initialize a new git repo with support for the branching model.
feature Manage your feature branches.
release Manage your release branches.
hotfix Manage your hotfix branches.
support Manage your support branches.
version Shows version information.
Try 'git flow <subcommand> help' for details.
详细的Gitflow使用方法参考Git Flow Cheatsheet
git flow init
使用默认值进行初始化设定
git flow feature start <feature-branch-name>
修改一些文件,添加修改的文件到暂存区(staging area)
git add .
将修改后的文件提交到本地的版本库中
git commit -am 'Add a new feature'
git flow feature finish <feature-branch-name>
git flow feature publish <feature-branch-name>
git checkout -b <release-branch-name> development
git add .
git commit -am 'Finish release related work'
git checkout master
git merge <release-branch-name>
git push
git checkout development
git merge <release-branch-name>
git push
git branch -d <release-branch-name>
git tag -a <version-number> -m 'Create 0.1 version release' master
git push --tags
git checkout -b <hotifx-branch-name> master
git add .
git commit -am 'Fix the crash bug'
git checkout master
git merge <hotifx-branch-name>
git push
git checkout development
git merge <hotifx-branch-name>
git push
git branch -d <hotifx-branch-name>