Git Flow: Unterschied zwischen den Versionen
| (13 dazwischenliegende Versionen von 2 Benutzern werden nicht angezeigt) | |||
| Zeile 28: | Zeile 28: | ||
Feature branches are checked out from the dev branch. Feature branches are merged back into the dev branch when the work is finished and deleted. These branches are normally only in a developer's development environment. If other developers need to have this code before it is finished Git Flow has a publish method that allows pushing the feature branch to the remote so other developers can then have access to it. | Feature branches are checked out from the dev branch. Feature branches are merged back into the dev branch when the work is finished and deleted. These branches are normally only in a developer's development environment. If other developers need to have this code before it is finished Git Flow has a publish method that allows pushing the feature branch to the remote so other developers can then have access to it. | ||
==== hotfix branches ==== | ==== hotfix branches ==== | ||
Hotfix branches are checked out from the live branch to fix a critical bug in the code on the live site. When finished, the hotfix branch should be merged to the test branch for testing. If all is well then the normal | Hotfix branches are checked out from the live branch to fix a critical bug in the code on the live site. When finished, the hotfix branch should be merged to the test branch for testing. If all is well then the normal <code>git flow hotfix finish</code> command can be used to merge it back into the live branch, and also merge it into the dev branch, so that the hotfix is included in the next release as well. | ||
==== bugfix branches ==== | ==== bugfix branches ==== | ||
Bugfix branches are checked out from the dev branch to fix bugs in the development branch. When | Bugfix branches are checked out from the dev branch to fix bugs in the development branch. When finished they are merged back into the dev branches Since late in 2012 the original Git Flow repository by Vincent Driessen on Github is no longer being updated. Peter van der Does started a new repository on Github in early 2012 called gitflow-avh. Ubuntu and other Linuxes have switched to this repository for the packages they include for git-flow. Bugfix branches are one of the new features that was added in the git-flow-avh (A VirtualHome). | ||
==== release branches ==== | ==== release branches ==== | ||
Release branches are used for both major and minor releases for stabilisation before a release. Release branches are taken off the dev branch then merged to both dev and live branches. Finally the live branch is tagged with the released version. | Release branches are used for both major and minor releases for stabilisation before a release. Release branches are taken off the dev branch then merged to both dev and live branches. Finally the live branch is tagged with the released version. | ||
| Zeile 38: | Zeile 38: | ||
=== Git Flow Branch Examples === | === Git Flow Branch Examples === | ||
Good images of how the different types of Git Flow branch methods work can be seen in the [https://gitversion.readthedocs.io/en/latest/git-branching-strategies/gitflow-examples/ GitFlow Examples in the Git Version documentation]. These images can help to give a very quick visual understanding of how the Git Flow branching method works. | Good images of how the different types of Git Flow branch methods work can be seen in the [https://gitversion.readthedocs.io/en/latest/git-branching-strategies/gitflow-examples/ GitFlow Examples in the Git Version documentation]. These images can help to give a very quick visual understanding of how the Git Flow branching method works. | ||
=== Git Flow Commands === | |||
See the documentation at the [https://github.com/petervanderdoes/gitflow-avh GitHub Repository for Git Flow AVH] for more information. | |||
==== Git Flow Initialization of new repository ==== | |||
To create a new git repo or to initialize the repository for the Git Flow commands run: | |||
git flow init | |||
In answer to the question: "Branch name for production releases: [master]" '''live''' | |||
In answer to the question: "Branch name for "next release" development: [develop]" '''dev''' | |||
To all other questions, accept the default answer. | |||
==== Git Flow List Branches ==== | |||
To list all branches of a type run: | |||
git flow <'''branch type name'''> | |||
To list feature branches: | |||
git flow feature | |||
To list hotfix branches: | |||
git flow hotfix | |||
==== Git Flow Start Branch ==== | |||
To start a branch of a type run: | |||
git flow <'''branch type name'''> start <name> [<base>] | |||
The '''<base>''' arg must be a branch, when omitted it defaults to the default for that Git Flow branch type. See the following table for the default starting branch for the Git Flow branch types. | |||
{| class="wikitable" | |||
! Git Flow Branch Type | |||
! Default Starting Branch | |||
|- | |||
|feature | |||
|dev | |||
|- | |||
|release | |||
|dev | |||
|- | |||
|hotfix | |||
|live | |||
|- | |||
|bugfix | |||
|dev | |||
|- | |||
|support | |||
|live | |||
|} | |||
To start a feature branch: | |||
git flow feature start <'''name'''> | |||
To start a bugfix branch: | |||
git flow bugfix start <'''name'''> | |||
==== Git Flow Finish Branch ==== | |||
To finish a branch of a type run: | |||
git flow <'''branch type name'''> finish <name> | |||
The '''<name>''' arg must be a branch, when omitted it defaults to the current branch if it is of the correct type. | |||
{| class="wikitable" | |||
! Git Flow Branch Type | |||
! Default Branch(es) committed to on finish | |||
|- | |||
|feature | |||
|dev | |||
|- | |||
|release | |||
|dev, live | |||
|- | |||
|hotfix | |||
|dev, live | |||
|- | |||
|bugfix | |||
|dev | |||
|- | |||
|support | |||
|dev, live | |||
|} | |||
To finish a bugfix branch: | |||
git flow bugfix finish | |||
To finish a support branch: | |||
git flow support finish | |||
==== Git Flow Delete Branch ==== | |||
When a branch is finished by default it is deleted. This command is only needed if it is decided to not commit a branch. | |||
To delete a branch of a type run: | |||
git flow <'''branch type name'''> delete | |||
To delete a feature branch: | |||
git flow feature delete | |||
To delete a bugfix branch: | |||
git flow bugfix delete | |||
==== Share features with others - git flow feature publish ==== | |||
You can easily publish a feature you are working on. The reason can be to allow other programmers to work on it or to access it from another machine. The publish/track feature of gitflow simplify the creation of a remote branch and its tracking. | |||
When you want to publish a feature just use: | |||
git flow feature publish <name> | |||
or, if you already are on the '''feature/<name>''' branch, just issue: | |||
git flow feature publish | |||
Now if you execute <code>git branch -avv</code> you will see that your branch feature/<name> tracks [origin/feature/<name>]. To track the same remote branch in another clone of the same repository use: | |||
git flow feature track <name> | |||
This will create a local feature feature/<name> that tracks the same remote branch as the original one, that is origin/feature/<name>. | |||
When one developer (depending on your work flow) finishes working on the feature he or she can issue git flow feature finish <name> and this will automatically delete the remote branch. All other developers shall then run: | |||
git flow feature delete <name> | |||
to get rid of the local feature that tracks a remote branch that no more exist. | |||
=== Using Hooks and Filters === | |||
For a wide variety of commands hooks or filters can be called before and after the Git Flow commands. | |||
The files should be placed in .git/hooks | |||
In the [https://github.com/petervanderdoes/gitflow-avh/tree/master/hooks directory hooks] of the [https://github.com/petervanderdoes/gitflow-avh git-flow-avh project] you can find examples of all the hooks available. | |||
=== Git Flow Cheat Sheet === | |||
Daniel Kummer's [http://danielkummer.github.io/git-flow-cheatsheet/ Git Flow Cheatsheet] is a great illustrated guide to Git Flow. | |||
[[Datei:Git_Flow_Cheatsheet.png|mini|right|Daniel Kummer's Git Flow Cheatsheet]] | |||
Aktuelle Version vom 23. Februar 2017, 07:10 Uhr
Git Flow is a collection of Git extensions to provide high-level repository operations for Vincent Driessen's Git Flow branching model (PDF Diagram of GitFlow branching). Git Flow does not take away the ability to use the normal Git commands. It does group together commands needed to carry out a Git Flow branching method step without the user needing to remember all the multiple necessary steps needed to finish what should be a simple step.
Vincent Driessen's Blog Post - "A successful Git branching model"
Vincent Driessen's Blog Post on Tuesday, January 05, 2010 titled "A successful Git branching model" is origin of what is called to today the Git Flow branching model.
Vincent Driessen Git Flow Diagram
Getting started - Introduction to Git Flow
For the best introduction to getting started with git flow, please read Jeff Kreeftmeijer's blog post:Using git-flow to automate your git branching workflow
Using Git Flow for Drupal Website Development
The Git Flow branching method can and is used by teams developing Drupal website. Depending on your deployment method some slight changes maybe needed. The names of the branches given in the original Git Flow method make sense for developing code but other names may make more sense when it is used for Drupal website development.
Branch Names
One important thing to note is that the branch names are only that names. There is nothing special about the branch names and you can setup the names to be what you want. I tried to use a set of branch names that were short but also described what the branch was used for in Drupal web development. The original names may make more sense when developing software code. I use the names from Shawn DeArmond's presentation at Bad Camp 2012 called "[ Development Workflow With Git]"(Blog Post) (PDF of Slides (slide 23 has the branch names))(Video of Presentation) as they made the most sense of any I saw. Here is a list of the branch names that I use with a reference to the branch name that Vincent used in his original article.
dev
(Originally develop) - This is the branch were development work is started from and merge back into.
test
This is the branch where code ideally gets tested in a environment identical to where it will be used live. In Drupal this is where the the code from the dev branch and the database from the live site can be tested together to see if things work as expected. This is an additional branch that is pushed to for deployment to the testing server. This branch is not in the original Git Flow branching method.
live
(Originally master) - This is the branch that is used on the live website. Pushing to this branch and then deploying results in the code going live.
feature branches
Feature branches are checked out from the dev branch. Feature branches are merged back into the dev branch when the work is finished and deleted. These branches are normally only in a developer's development environment. If other developers need to have this code before it is finished Git Flow has a publish method that allows pushing the feature branch to the remote so other developers can then have access to it.
hotfix branches
Hotfix branches are checked out from the live branch to fix a critical bug in the code on the live site. When finished, the hotfix branch should be merged to the test branch for testing. If all is well then the normal git flow hotfix finish command can be used to merge it back into the live branch, and also merge it into the dev branch, so that the hotfix is included in the next release as well.
bugfix branches
Bugfix branches are checked out from the dev branch to fix bugs in the development branch. When finished they are merged back into the dev branches Since late in 2012 the original Git Flow repository by Vincent Driessen on Github is no longer being updated. Peter van der Does started a new repository on Github in early 2012 called gitflow-avh. Ubuntu and other Linuxes have switched to this repository for the packages they include for git-flow. Bugfix branches are one of the new features that was added in the git-flow-avh (A VirtualHome).
release branches
Release branches are used for both major and minor releases for stabilisation before a release. Release branches are taken off the dev branch then merged to both dev and live branches. Finally the live branch is tagged with the released version.
support branches
Support branches are not really covered in GitFlow, but are essential if you need to maintain multiple major versions at the same time. You could use support branches for supporting minor releases as well. Support branches were added in git-flow-avh.
Git Flow Branch Examples
Good images of how the different types of Git Flow branch methods work can be seen in the GitFlow Examples in the Git Version documentation. These images can help to give a very quick visual understanding of how the Git Flow branching method works.
Git Flow Commands
See the documentation at the GitHub Repository for Git Flow AVH for more information.
Git Flow Initialization of new repository
To create a new git repo or to initialize the repository for the Git Flow commands run:
git flow init
In answer to the question: "Branch name for production releases: [master]" live
In answer to the question: "Branch name for "next release" development: [develop]" dev
To all other questions, accept the default answer.
Git Flow List Branches
To list all branches of a type run:
git flow <branch type name>
To list feature branches:
git flow feature
To list hotfix branches:
git flow hotfix
Git Flow Start Branch
To start a branch of a type run:
git flow <branch type name> start <name> [<base>]
The <base> arg must be a branch, when omitted it defaults to the default for that Git Flow branch type. See the following table for the default starting branch for the Git Flow branch types.
| Git Flow Branch Type | Default Starting Branch |
|---|---|
| feature | dev |
| release | dev |
| hotfix | live |
| bugfix | dev |
| support | live |
To start a feature branch:
git flow feature start <name>
To start a bugfix branch:
git flow bugfix start <name>
Git Flow Finish Branch
To finish a branch of a type run:
git flow <branch type name> finish <name>
The <name> arg must be a branch, when omitted it defaults to the current branch if it is of the correct type.
| Git Flow Branch Type | Default Branch(es) committed to on finish |
|---|---|
| feature | dev |
| release | dev, live |
| hotfix | dev, live |
| bugfix | dev |
| support | dev, live |
To finish a bugfix branch:
git flow bugfix finish
To finish a support branch:
git flow support finish
Git Flow Delete Branch
When a branch is finished by default it is deleted. This command is only needed if it is decided to not commit a branch.
To delete a branch of a type run:
git flow <branch type name> delete
To delete a feature branch:
git flow feature delete
To delete a bugfix branch:
git flow bugfix delete
Share features with others - git flow feature publish
You can easily publish a feature you are working on. The reason can be to allow other programmers to work on it or to access it from another machine. The publish/track feature of gitflow simplify the creation of a remote branch and its tracking.
When you want to publish a feature just use:
git flow feature publish <name>
or, if you already are on the feature/<name> branch, just issue:
git flow feature publish
Now if you execute git branch -avv you will see that your branch feature/<name> tracks [origin/feature/<name>]. To track the same remote branch in another clone of the same repository use:
git flow feature track <name>
This will create a local feature feature/<name> that tracks the same remote branch as the original one, that is origin/feature/<name>.
When one developer (depending on your work flow) finishes working on the feature he or she can issue git flow feature finish <name> and this will automatically delete the remote branch. All other developers shall then run: git flow feature delete <name> to get rid of the local feature that tracks a remote branch that no more exist.
Using Hooks and Filters
For a wide variety of commands hooks or filters can be called before and after the Git Flow commands. The files should be placed in .git/hooks In the directory hooks of the git-flow-avh project you can find examples of all the hooks available.
Git Flow Cheat Sheet
Daniel Kummer's Git Flow Cheatsheet is a great illustrated guide to Git Flow.