Руководство по веткам (Git и Qt)
Материал из Wiki.crossplatform.ru
Содержание |
Guidelines for creating, maintaining and closing Branches
These guidelines will help you to avoid creating a forest of branches of development and merging hell. Stick to simple rules and you will find it easier to maintain and merge separate code lines.
Creating a new feature branch
When creating a new branch, you have to decide on a base branch to start off of. Properties of good base branches are:
- Stable
- Long-lived
- Maintained
In addition you may want to back up your new branch somewhere, so pick a location:
- A personal clone of your project.
- A team repository.
Maintaing and updating a branch
As a rule of thumb, try to pull updates only from your base branch. Avoid pulling from experimental branches into your feature branch. Don’t pull other project’s branches into your feature branch unless you decide to become part of the project.
Closing a branch
When you’re done with your feature, decide where to merge it back. Your options include:
- The most straightforward target is your base branch. Merge into it and delete your feature branch.
- You may also choose to merge your feature branch into another project’s feature branch, and then close yours.
- If you would like to take only the changes that you've done and merge them into another branch, without including the changes of your base branch, then you can use git rebase. It can be a complex operation and works best on relatively small changesets.
Experimental work
A common situation is that you have two separate feature branches and you would like to try out how both of them behave together. Simply create a third, short-lived branch based on the one feature branch and with the second one merged into it. If in the process of testing the combination of both branches you discover that additional changes are needed, then you can commit them first into your experimental branch. Afterwards use git-cherry-pick
to pick them into one of the two originating branches and delete your experimental branch again.