Skip to content

Instantly share code, notes, and snippets.

@mrtonyhuynh
Last active August 29, 2015 14:21
Show Gist options
  • Save mrtonyhuynh/ab266523e855064fe03d to your computer and use it in GitHub Desktop.
Save mrtonyhuynh/ab266523e855064fe03d to your computer and use it in GitHub Desktop.
Git Workflow

Khởi tạo

Historical Branches

Tạo branch develop cho dự án

git branch develop
git push -u origin develop

Checkout branch develop đối với cộng tác viên

git clone ssh://user@host/path/to/repo.git
git checkout -b develop origin/develop

Phát triển dự án

Feature Branches

Tạo nhánh mới để bắt đầu với một (nhóm) tính năng mới dựa trên nhánh develop

git checkout -b some-feature develop

Commit các thay đổi

git status
git add <some-file>
git commit

Kết thúc và gộp nhánh tính năng vào branch develop

git pull origin develop
git checkout develop
git merge some-feature
git push
git branch -d some-feature

Phát hành

Release Branches

Chuẩn bị bản Release (làm sạch code, kiểm thử, bổ sung tài liệu hướng dẫn)

git checkout -b release-0.1 develop

Release

git checkout master
git merge release-0.1
git push
git checkout develop
git merge release-0.1
git push
git branch -d release-0.1

git tag -a 0.1 -m "Initial public release" master
git push --tags

Bảo trì dự án

Maintenance Branches

Bảo trì, sửa lỗi

git checkout -b issue-#001 master
# Merge the hotfix to Master
git checkout master
git merge issue-#001
git push
# Merge the hotfix to Develop
git checkout develop
git merge issue-#001
git push
git branch -d issue-#001

More

Khởi tạo

Clone dự án có sẵn

git clone https://user@bitbucket.org/user/repo.git

Gắn remote upstream

git remote add upstream https://user@bitbucket.org/maintainer/repo.git

Dành cho Developer

Develop dựa trên nhánh tính năng có sẵn (Cộng tác viên)

git checkout -b some-feature
# Edit some code
git commit -a -m "Add first draft of some feature"
git pull upstream master
git push origin feature-branch

Đồng bộ với Repo

git pull upstream master

Dành cho Maintainer

Review và Merge nhánh tính năng do cộng tác viên push lên

(Nếu không cần review thì merge trực tiếp bằng lệnh git pull)

git fetch https://bitbucket.org/user/repo feature-branch
# Inspect the changes
git checkout master
git merge FETCH_HEAD
git push origin master

More

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment