Skip to content

Instantly share code, notes, and snippets.

@crossi202
Last active March 17, 2020 03:02
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save crossi202/2782b96481da1134c337 to your computer and use it in GitHub Desktop.
Save crossi202/2782b96481da1134c337 to your computer and use it in GitHub Desktop.
CheatSheet for the Git Flow process introduced by Vincent Driessen, using as remote a SVN repository

Git-Flow SVN Cheatsheet

In this cheatsheet, the Git Flow process is followed using the tools:

  • git svn
  • svn
  • git

Prerequisites

  • The SVN repository has the standard layout with trunk, tags, branches.

Initialize the Repository for the Git Flow process:

  • Clone the repository with:
    $ git svn clone --prefix origin/ -s <svn repo root URL>

Tip. If the SVN history is too long, use the -r option to restrict the number of revisions to be cloned. For example:

    $ git svn clone --prefix origin/ -r<revision>:HEAD -s <svn repo root URL>
  • Create the remote branch develop, based on the master branch (only if the branch develop is not present in the remote SVN repository):
    $ git svn branch develop
  • Create a local develop branch, linked to the remote develop branch:
    $ git checkout -b develop origin/develop

Features

Start a new Feature

  • Ensure that the current git branch is develop:
    $ git branch
    * develop
    master
  • Create a remote feature branch, based on the develop branch:
    $ git svn branch feature-<featurename> #[1]
  • Create a local feature branch, linked to the remote feature branch:
    $ git checkout -b feature/<featurename> origin/feature-<featurename>

Develop a Feature

To develop a feature, just work as usual using the git commands like git add and git commit and ensuring you are working in the correct local branch:

    $ git branch
    develop
    * feature/<featurename>
    master

Publish a Feature

  • Push a feature branch to the remote repository:
    $ git svn dcommit [2]

Finish a Feature

  • Merge the feature branch into develop:
    $ git checkout develop
    $ git svn rebase
    $ git merge feature/<featurename>
  • Publish the develop branch on the remote repository:
    $ git svn dcommit [2]
  • Delete the feature branch:
    $ git branch -D feature/<featurename>
    $ svn rm <svn repo root URL>/branches/feature-<featurename>

Hotfixes

Start a Hotfix

Finish a Hotfix

Releases

Start a new Release

  • Ensure that the current git branch is develop:
    $ git branch
    * develop
    master
  • Create a remote release branch, based on the develop branch:
    $ git svn branch release-<releasename>
  • Create a local release branch, linked to the remote release branch:
    $ git checkout -b release/<releasename> origin/release-<releasename>

Prepare the Release

To prepare a release, fix the release version in the proper resources (e.g. pom.xml), and work as usual using the git commands like git add and git commit ensuring you are working in the correct local branch:

    $ git branch
    develop
    * release/<releasename>
    master

Publish a Release

  • Push a release branch to the remote repository:
    $ git svn dcommit [2]

Finish a Release

A. Merge into master

  • Merge the release branch into master:
    $ git checkout master
    $ git merge release/<releasename>
  • Change the remote SVN reference, to be sure that the remote trunk is used:
    git reset origin/trunk
  • Commit the merge:
    $ git commit -am "Merge branch release/<releasename>"
  • Publish the master branch and the tag on the remote repository:
    $ git svn dcommit [2]
    $ git svn tag <releasename>

B. Merge into develop

  • Merge the release branch into develop:
    $ git checkout develop
    $ git merge release/<releasename>
  • Change the remote SVN reference, to be sure that the remote develop is used:
    git reset origin/develop
  • Commit the merge:
    $ git commit -am "Merge branch release/<releasename>"
  • Publish the develop branch on the remote repository:
    $ git svn dcommit [2]

C. Delete the release branch

  • Delete the release branch:
    $ git branch -D release/<releasename>
    $ svn rm <svn repo root URL>/branches/release-<releasename>

[1] As it is suggested to use the of a tracker system. [2] When you perform a git svn dcommit, check if all is OK using the option --dry-run (in particular check if the remote branch is correct).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment