A Git Workflow Model Slides produced from blog by Vincent Driessen http://nvie.com/git-model and secondary posting at http://gist.github.com/287237 The.

Slides:



Advertisements
Similar presentations
DEV306. LEGEND Branching / Merging point Development Test Production R1 R2 R3 Branch On Test Development Test Production Branch On Test.
Advertisements

Version Control What it is and why you want it. What is Version Control? A system that manages changes to documents, files, or any other stored information.
Concepts of Version Control A Technology-Independent View.
VisIt Software Engineering Infrastructure and Release Process LLNL-PRES Lawrence Livermore National Laboratory, P. O. Box 808, Livermore,
Software Configuration Management
Automating Drupal Deployment Dominique De Cooman.
Version Control with git. Version Control Version control is a system that records changes to a file or set of files over time so that you can recall.
1 CSE 390 “Lecture 11” Version control with Git slides created by Ruth Anderson, images from
BIT 285: ( Web) Application Programming Lecture 07 : Tuesday, January 27, 2015 Git.
Git: Part 1 Overview & Object Model These slides were largely cut-and-pasted from tutorial/, with some additions.
Git for Version Control These slides are heavily based on slides created by Ruth Anderson for CSE 390a. Thanks, Ruth! images taken from
Overview of Git Workflows for CSE Software Trilinos Spring Developers Meeting May 13, 2015 Roscoe A. Bartlett Oak Ridge National Lab Computational Eng.
Introduction to Version Control with SVN & Git CSC/ECE 517, Fall 2012 Titus Barik & Ed Gehringer, with help from Gaurav.
WARNING These slides are not optimized for printing or exam preparation. These are for lecture delivery only. These slides are made for PowerPoint 2010.
Introduction to Version Control
Git – versioning and managing your software L. Grewe.
Branching. Version Control - Branching A way to write code without affecting the rest of your team Merge branches to integrate your changes.
Puppet with vSphere Workshop Install, configure and use Puppet on your laptop for vSphere DevOps Billy Lieberman August 1, 2015.
Version Control Systems academy.zariba.com 1. Lecture Content 1.What is Software Configuration Management? 2.Version Control Systems (VCS) 3.Basic Git.
Git workflow and basic commands By: Anuj Sharma. Why git? Git is a distributed revision control system with an emphasis on speed, data integrity, and.
Information Systems and Network Engineering Laboratory II DR. KEN COSH WEEK 1.
Development Environment Matthew Sell, CSSE Student MASS Research Participant, October 2014.
Continuous Processes By Kelvin Zhu CSCI577B Spring 2013.
Computer Science and Engineering The Ohio State University  Widely used, especially in the opensource community, to track all changes to a project and.
Code and Asset Branching Best Practices Session 315 Philip Wolfe, Lead Developer Farm Credit Services of America.
Introduction to Version Control with Git CSC/ECE 517, Fall 2014 A joint project of the CSC/ECE 517 staff, including Titus Barik, Gaurav Tungatkar, Govind.
Version Control and SVN ECE 297. Why Do We Need Version Control?
Introduction to Git Yonglei Tao GVSU. Version Control Systems  Also known as Source Code Management systems  Increase your productivity by allowing.
USM - IT BRANCHING PRESENTATION. Branch copying a codeline to create a new one codelines evolve independently //depot/main/...
ATS code development workflow Group Name: TST WG Source: Mahdi Ben Alaya, TST WG vice chair, SENSINOV, Miguel.
ATS code development workflow Group Name: TST WG Source: Mahdi Ben Alaya, TST WG vice chair, SENSINOV, Meeting Date: TST #21 Document.
ONE LAPTOP PER CHILD This works are licensed under a Creative Commons Attribution 2.5 License. One Laptop per Child Builds, Customizations and Localization.
ATS code development workflow Group Name: TST WG Source: Mahdi Ben Alaya, TST WG vice chair, SENSINOV, Miguel.
It’s not just an insult from Harry Potter!. What is Git? Distributed Version Control System (DVCS) – Compared to a Centralized Version Control System.
Information Systems and Network Engineering Laboratory I DR. KEN COSH WEEK 1.
1 Ivan Marsic Rutgers University LECTURE 2: Software Configuration Management.
CS520 Web Programming Version Control with Subversion Chengyu Sun California State University, Los Angeles.
1. A new git is initialized as a remote repository JohnRemote repositoryPeter master C0 CodingWhileBlack.com PROPEL CODING
BIT 285: ( Web) Application Programming Lecture 07 : Tuesday, January 27, 2015 Git.
ONAP VNF Requirements project Workflow
Version Control for PL/SQL
CompSci 230 Software Construction
CS5220 Advanced Topics in Web Programming Version Control with Git
Introduction to Version Control with Git
4 Version control (part 1)
Information Systems and Network Engineering Laboratory II
Git and GitHub primer.
Software Packaging and Releasing
LECTURE 2: Software Configuration Management
Git Practice walkthrough.
OpSim Configuration Management Michael Reuter
CS5220 Advanced Topics in Web Programming Version Control with Git
Software Engineering for Data Scientists
Macaualy2 Workshop Berkeley 2017
Distributed Version Control with git
Akshay Narayan git up to speed with RCS Akshay Narayan
Anatomy of a Git Project
LECTURE 3: Software Configuration Management
The Big Picture
Collaboration Work Flow with Git
Git Best Practices Jay Patel Git Best Practices.
Quality Assurance in an Agile Development Team Michelle Wu 2018 PNSQC
Git and Jira Tutorials Kan Qi
Version control with Git
Version Control with Git
Tango 9 LTS NEWS Kernel meeting Krakow February 2019
Git Introduction.
Branches And Releases Branch for Urgent Bug Branch for Feature A
Software Engineering and Architecture
Interoperability Testing
Presentation transcript:

A Git Workflow Model Slides produced from blog by Vincent Driessen http://nvie.com/git-model and secondary posting at http://gist.github.com/287237 The first few slides are cut-ups from a large diagram, which can be found in PDF at Vincent Driessen’s website, along with the rest of the material here. I have reformatted it here for classroom presentation.

The big picture Original blog by Vincent Driessen I first found this example on a web page of the Apache Portable Runtime Project. They had taken it from a blog by Vincent Driessen. This is a good example of how to use Git on a medium-sized development project, as well as a good version numbering scheme. The images and text below are all reproduced from those web pages, with just a few modifications, reformatted for classroom use. This project uses a “semantic version numbering” system. Versions are denoted using a standard triplet of integers: MAJOR.MINOR.PATCH. The basic intent is that MAJOR versions are incompatible, large-scale upgrades of the API. MINOR versions retain source and binary compatibility with older minor versions, and changes in the PATCH level are perfectly compatible, forwards and backwards. Patch level changes could also be for correcting incorrect APIs. In this case, the previous patch release may be incompatible, but because of bugs. Minor versions may introduce new features, but do not alter any of the previous API. Major versions may introduce new features and change the old API in incompatible ways. For background see description of Semantic Versioning at http://semver.org/. The different types of branches are: master production releases develop AKA integration branch Release branches (release-*) for finalizing a major/minor release, branched from develop Hotfix branches (hotfix-*) for applying patches, branched from master (or support-* for older releases) Support branches (support-*) for applying patches to old release versions, branched from master Feature branches (feature-*) for developing features or wild speculation, branched from develop Original blog by Vincent Driessen http://nvie.com/git-model

http://nvie.com/git-model

http://nvie.com/git-model

Repository relationships From here on I quote from the original blog. The repository setup is that with a central “truth” repo. Note that this repo is only considered to be the central one (since Git is a DVCS, there is no such thing as a central repo at a technical level). We will refer to this repo as origin, since this name is familiar to all Git users. Each developer pulls and pushes to origin. But besides the centralized push-pull relationships, each developer may also pull changes from other peers to form sub teams. For example, this might be useful to work together with two or more developers on a big new feature, before pushing the work in progress to origin prematurely. In the figure above, there are subteams of Alice and Bob, Alice and David, and Clair and David. Technically, this means nothing more than that Alice has defined a Git remote, named bob, pointing to Bob’s repository, and vice versa. http://nvie.com/git-model

Main branches master used for production releases develop used for integration and regression testing The central repository holds two main branches with an infinite lifetime: master Develop The master branch at origin should be familiar to every Git user.  Parallel to the master branch, another branch exists called develop. We consider origin/master to be the main branch where the source code of HEAD always reflects a production-ready state. We consider origin/develop to be the main branch where the source code of HEAD always reflects a state with the latest delivered development changes for the next release. Some would call this the “integration branch”. This is where any automatic nightly builds are built from. When the source code in the develop branch reaches a stable point and is ready to be released, all of the changes should be merged back into master somehow and then tagged with a release number. How this is done in detail will be discussed further on. Therefore, each time when changes are merged back into master, that is a new production release by definition. We tend to be very strict at this, so that theoretically, we could use a Git hook script to automatically build and roll-out our software to our production servers every time there was a commit on master. Next to the main branches master and develop, our development model uses a variety of supporting branches to aid parallel development between team members, ease tracking of features, prepare for production releases and to assist in quickly fixing live production problems. Unlike the main branches, these branches always have a limited life time, since they will be removed eventually. The different types of branches we may use are: Feature branches Release branches Hotfix branches Each of these branches have a specific purpose and are bound to strict rules as to which branches may be their originating branch and which branches must be their merge targets. We will walk through them in a minute. By no means are these branches “special” from a technical perspective. The branch types are categorized by how we use them. They are of course plain old Git branches. May branch off from: develop Must merge back into: develop Branch naming convention: anything except master, develop, release-*, or hotfix-* Feature branches (or sometimes called topic branches) are used to develop new features for the upcoming or a distant future release. When starting development of a feature, the target release in which this feature will be incorporated may well be unknown at that point. The essence of a feature branch is that it exists as long as the feature is in development, but will eventually be merged back into develop (to definitely add the new feature to the upcoming release) or discarded (in case of a disappointing experiment). Feature branches typically exist in developer repos only, not in origin. http://nvie.com/git-model

Feature branches http://nvie.com/git-model Feature branches Created for feature development that may require several or more commits to produce a working tree. May make occasional merges from develop to keep it up to date. If it will be separate for an extended period of time, create a feature-branch-readme.txt in the top level directory dictating the reason for the branch. May branch off from: develop Creating a feature branch When starting work on a new feature, branch off from the develop branch. $ git checkout -b myfeature develop Switch to a new branch "myfeature" Incorporating a finished feature on develop Finished features must be merged into the develop branch to add them to the upcoming release: $ git checkout develop Switch to branch 'develop' $ git merge --no-ff myfeature Update ea1b82a..05e9557 (Summary of changes) $ git branch -d myfeature Delete branch myfeature (was 05e9557). $ git push origin develop The --no-ff flag causes the merge to always create a new commit object, even if the merge could be performed with a fast-forward. This avoids losing information about the historical existence of a feature branch and groups together all commits that together added the feature. In the latter case, it is impossible to see from the Git history which of the commit objects together have implemented a feature—you would have to manually read all the log messages. Reverting a whole feature (i.e. a group of commits), is a true headache in the latter situation, whereas it is easily done if the --no-ff flag was used. Yes, it will create a few more (empty) commit objects, but the gain is much bigger that that cost. Unfortunately, I have not found a way to make --no-ff the default behaviour of git merge yet, but it really should be. http://nvie.com/git-model

Release branches Branched from develop when it almost reflects the desired new release Bug fixes for the release are applied here No new features may be added to this branch New feature development can continue in parallel on the develop branch Release Branches Release branches are created from the develop branch when the develop branch is at a stable point and release specific changes need to be made, such as bumping version numbers, etc. At that point, develop should be branched and the changes made before ultimately merging it into master and tagging the release. There should only be one active release branch at a time. Until the current release is wrapped up, merged into master and deleted, development of the next release should take place on develop. When develop reaches another state of stability for release, another release branch is be created. May branch off from: develop Must merge back into: develop and master Branch naming convention: release-* Release branches support preparation of a new production release. They allow for last-minute dotting of i’s and crossing t’s. Furthermore, they allow for minor bug fixes and preparing meta-data for a release (version number, build dates, etc.). By doing all of this work on a release branch, the develop branch is cleared to receive features for the next big release. The key moment to branch off a new release branch from develop is when develop (almost) reflects the desired state of the new release. At least all features that are targeted for the release-to-be-built must be merged in to develop at this point in time. All features targeted at future releases may not—they must wait until after the release branch is branched off. It is exactly at the start of a release branch that the upcoming release gets assigned a version number—not any earlier. Up until that moment, the develop branch reflected changes for the “next release”, but it is unclear whether that “next release” will eventually become 0.3 or 1.0, until the release branch is started. That decision is made on the start of the release branch and is carried out by the project’s rules on version number bumping. Creating a release branch $ git checkout -b release-1.2 develop Switched to a new branch "release-1.2” $ ./bump-version.sh 1.2 Files modified successfully, version bumped to 1.2. $ git commit -a -m "Bumped version number to 1.2" [release-1.2 74d9424] Bumped version number to 1.2 1 files changed, 1 insertions(+), 1 deletions(-) After creating a new branch and switching to it, we bump the version number. Here, bump-version.sh is a fictional shell script that changes some files in the working copy to reflect the new version. (This can of course be a manual change—the point being that some files change.) Then, the bumped version number is committed. This new branch may exist there for a while, until the release may be rolled out definitely. During that time, bug fixes may be applied in this branch (rather than on the develop branch). Adding large new features here is strictly prohibited. They must be merged into develop, and therefore, wait for the next big release. Finishing a release branch When the state of the release branch is ready to become a real release, some actions need to be carried out. First, the release branch is merged into master (since every commit on master is a new release by definition, remember). Next, that commit on master must be tagged for easy future reference to this historical version. Finally, the changes made on the release branch need to be merged back into develop, so that future releases also contain these bug fixes. The first two steps in Git: $ git checkout master Switched to branch 'master' $ git merge --no-ff release-1.2 Merge made by recursive. (Summary of changes) $ git tag -a 1.2 The release is now done, and tagged for future reference. (You might as well want to use the -s or -u <key> flags to sign your tag cryptographically.) To keep the changes made in the release branch, we need to merge those back into develop, though. In Git: $ git checkout develop Switched to branch 'develop' This step may well lead to a merge conflict (probably even, since we have changed the version number). If so, fix it and commit. Now we are really done and the release branch may be removed, since we don’t need it anymore: $ git branch -d release-1.2 Deleted branch release-1.2 (was ff452fe).

Hotfix Branches Are like release branches, but for bug fixes Patches that need to be made to the most recent production release are applied to a hotfix branch off master. For older releases, hotfixes branch off a support-* branch (explained later.) May branch off from: master Must merge back into: develop and master Branch naming convention: hotfix-* Hotfix branches are very much like release branches in that they are also meant to prepare for a new production release, albeit unplanned. They arise from the necessity to act immediately upon an undesired state of a live production version. When a critical bug in a production version must be resolved immediately, a hotfix branch may be branched off from the corresponding tag on the master branch that marks the production version. The essence is that work of team members (on the develop branch) can continue, while another person is preparing a quick production fix. Creating the hotfix branch Hotfix branches are created from the master branch. For example, say version 1.2 is the current production release running live and causing troubles due to a severe bug. But changes on develop are yet unstable. We may then branch off a hotfix branch and start fixing the problem: $ git checkout -b hotfix-1.2.1 master Switched to a new branch "hotfix-1.2.1" $ ./bump-version.sh 1.2.1 Files modified successfully, version bumped to 1.2.1. $ git commit -a -m "Bumped version number to 1.2.1” [hotfix-1.2.1 41e61bb] Bumped version number to 1.2.1 1 files changed, 1 insertions(+), 1 deletions(-) Don’t forget to bump the version number after branching off! Then, fix the bug and commit the fix in one or more separate commits. $ git commit -m "Fixed severe production problem” [hotfix-1.2.1 abbe5d6] Fixed severe production problem 5 files changed, 32 insertions(+), 17 deletions(-) Finishing a hotfix branch When finished, the bugfix needs to be merged back into master, but also needs to be merged back into develop, in order to safeguard that the bugfix is included in the next release as well. This is completely similar to how release branches are finished. First, update master and tag the release. $ git checkout master Switched to branch 'master' $ git merge --no-ff hotfix-1.2.1 Merge made by recursive. (Summary of changes) $ git tag -a 1.2.1 (You might as well want to use the -s or -u <key> flags to sign your tag cryptographically. Next, include the bugfix in develop, too: $ git checkout develop Switched to branch 'develop' The one exception to the rule here is that, when a release branch currently exists, the hotfix changes need to be merged into that release branch, instead of develop. Back-merging the bugfix into the release branch will eventually result in the bugfix being merged into develop too, when the release branch is finished. (If work in develop immediately requires this bugfix and cannot wait for the release branch to be finished, you may safely merge the bugfix into develop now already as well.) Finally, remove the temporary branch: $ git branch -d hotfix-1.2.1 Deleted branch hotfix-1.2.1 (was abbe5d6). http://nvie.com/git-model

Support Branches If master has moved on to a new and a hotfix must be applied to a older version ( e.g 1.x): create a support-1.x branch (if none exists) based on the newest 1.x tag in master create a branch (e.g. hotfix-1.1.1), based on support-1.x fix the bug and merge hotfix-1.1.1 back into support-1.x Do this for other older major releases as necessary The support branch effectively becomes a master branch for a past version. This is a distinction added by http://gist.github.com/287237, for hotfixes to old releases. If master has moved on a point release (1.0, 1.1, 2.0, etc) and a hotfix must be applied to a older version ( e.g 1.x): create a support-1.x branch (if none exists) based on the newest 1.x tag in master create a branch (e.g. hotfix-1.1.1), based on support-1.x fix the bug and merge hotfix-1.1.1 back into support-1.x Do this for other older major releases as necessary The support branch effectively becomes a master branch for a past version.