1 branch specification
master | Main branch |
---|---|
dev | The main development branch |
hotfix | Bug fix branch |
feature | Function development branch |
1.1 main branch master
master branch is always protected. Branch that is not on the master, a commit, push operation.
receiving the master branch merge operation only.
Each release of the stable version formally launched (the first days after release), the current release version to merge the master branch.
master branch line code and the code is always synchronized.
1.2 Development of the main branch dev
- dev branch main development branch. You can commit, push, merge operation.
- Dev generally not the development of new features on the branch. dev branch code is used for integration of different branches.
After each master release, you need to master code merge onto dev. Stay updated than the master code.
1.3 hotfix branch hotfix / xxxx
- hotfix branch checkout branched by the master, with a hot fix bug line. You can commit, push, merge operation.
Published directly after the repair is completed validated. After the completion of release to merge the master branch.
1.4 Functional development branch feature / xxxx
- New features for branch development. This branch of the checkout dev branched, can commit, push, merge operation.
- Or by function version may feature multiple branches simultaneously checkout parallel development. Completion of the development unified merge back into dev.
2 Workflow
2.1 development of new features
- Development branch, such as the feature / new branch from dev checkout.
- Submit test after development is completed. After testing by modifying the version number on the package.json released by the responsible person (usually the team leader), fill out the changelog.
- After the completion of the official release, issued by the person responsible for the release of version merge into the master branch.
- Finally, the master branch merge into the dev branch.
2.2 hotfix hot fixes
- Repair branch, such as the hotfix / newbug heat from the master branch checkout.
- Submit test after the repair is complete. After testing by modifying the version number on the package.json released by the responsible person (usually the team leader), fill out the changelog.
- After the completion of the official release, issued by the person responsible for the hotfix to merge the master branch.
- Finally, the master branch merge into the dev branch.
2.3 Parallel development
- Dev checkout branches from a plurality of parallel branches developed, such as feature / new1, feature / new2, feature / new3 ....
- Merged into a unified dev after development is completed by the publisher in charge (usually the team leader) will be developed in parallel branch statistics or on a new feature branch. (Mainly to see if there are multiple release schedule in the short term)
- Submit test. After testing by modifying the version number on the package.json released by the responsible person, fill in changelog.
- After the completion of the official release, issued by the person responsible for the release of version merge into the master branch.
- Finally, the master branch merge into the dev branch.
3 Notes
- As long as the official release to the environment, no matter how many changes, each must change the version number, while leaving the changelog record.
- After each official release to the environment must remember synchronization code back to the dev.
- In addition to all branches master, dev three types of branches are temporary branch. After the branch may be appropriate to retain a version of the 1-2 remove other branches.
- Develop good habits, before each development, before submitting code first synchronization code.
Knowledge Point 4 GIT refining
4.1 GIT of common operations
operating | description | Explanation |
---|---|---|
git pull | And pulling merge code | Syntactic sugar fetch, diff and merge, since performed automatically merge, can easily lead to a conflict did not notice, not recommended |
git fetch origin xxx | Pulling the distal end of the code without merging | recommend |
git merge origin/xxx | The combined code to the current branch | recommend |
git status -s | View a list of file changes | |
git branch | View all local branches | |
git branch -a | Check local and remote branch | |
git branch -d xxx | Delete the local branch xxx | Xxx can not be deleted on branch |
git checkout xxx | Xxx switched to the branch | xxx branch must exist |
git checkout -b xxx | New local branch xxx xxx switched to the branch and | xxx branch must not exist |
git add . | Submit changes to all local workspace to the local staging area | |
git commit -m 'Note' | Submit to the corresponding local staging area on the local branch | |
git push | The code on the local branch pushed to the distal branch | |
git log | View current commit record on the branch | |
git reset --hard xxxx | Reply to the local version xxxx (git log record found in the commit hash number) |