Skip to content

Instantly share code, notes, and snippets.

@imty42
Created October 31, 2015 10:44
Show Gist options
  • Save imty42/7f126e06cc9355c92da7 to your computer and use it in GitHub Desktop.
Save imty42/7f126e06cc9355c92da7 to your computer and use it in GitHub Desktop.
GIT 开发流程

1. 初始化

git clone some-git-url proj-name
cd proj-name
git config --local user.name your.name
git config --local user.email your.email
git config --global core.editor vim

2. 创建新分支,请参考 git 分支规范 “feature 分支命名规则”部分

git checkout develop
git pull
git branch feature/awsome_feature-me-today

3. 开发自测提交

# do some rock and roll
git add .
git commit -m "about what really did"
git push origin feature/awsome_feature-me-today

4. 测试环境验证

# 切换前应保证当前没有改动的文件
git checkout develop
git pull

# --no-ff 可以保留分支记录,帮助我们回顾时了解代码来源
git merge --no-ff feature/awsome_feature-me-today

# 有时会出现代码冲突,请耐心编辑冲突、标记解决
git commit -m "merge from feature/awsome_feature-me-today"
git push origin develop

# 登录测试机器执行
sudo -u www /data0/scripts/deploy_dev

5. 预上线

# 为避免上线影响开发,在完成当前主体开发后,从develop分支分出release分支
# 更新和bug修复直接在这个分支,确定无误后合并至master
git pull
git checkout -b release/today develop

# 修复 bug、检查没问题后合并到 master、develop 分支并删除
git checkout master
git pull
# --no-ff 可以保留分支记录,帮助我们回顾时了解代码来源
git merge --no-ff release/today
git checkout develop
git pull
git merge --no-ff release/today

# 当确认无误可以删除此分支
git branch -d release/today

6. 上线

# 切换前应保证当前没有改动的文件
git checkout master
git pull
git merge --no-ff feature/awsome_feature-me-today
# 有时会出现代码冲突,请耐心编辑冲突、标记解决
git commit -m "merge from feature/awsome_feature-me-today"
git push origin master

# 登录线上机器执行上线脚本,请保证使用www账户执行
sudo -u www /data1/dep_deploy/clientapi/deplpy

7. 打补丁,请参考 git 分支规范 “快速修复分支”部分。

git pull
git checkout -b hotfix/fix_a_bug-me-today master

# 完成测试,准备上线

git pull
git checkout master

# 使用选项 --no-ff(No fast forward)进行合并
git merge --no-ff hotfix/fix_a_bug-me-today
git push origin master

# 上线后将分支合并回develop
git pull
git checkout develop
git merge --no-ff hotfix/fix_a_bug-me-today
git push origin develop

# 当确认无误可以删除此分支
git branch -d hotfix/fix_a_bug-me-today
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment