Руководство по веткам (Git и Qt)

Материал из Wiki.crossplatform.ru

Версия от 22:18, 24 июня 2009; Lit-uriy (Обсуждение | вклад)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Содержание

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:

  1. Stable
  2. Long-lived
  3. Maintained

In addition you may want to back up your new branch somewhere, so pick a location:

  1. A personal clone of your project.
  2. 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:

  1. The most straightforward target is your base branch. Merge into it and delete your feature branch.
  2. You may also choose to merge your feature branch into another project’s feature branch, and then close yours.
  3. 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.