In this cheatsheet, the Git Flow process is followed using the tools:
- git svn
- svn
- git
- The SVN repository has the standard layout with trunk, tags, branches.
- 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 themaster
branch (only if the branchdevelop
is not present in the remote SVN repository):
$ git svn branch develop
- Create a local
develop
branch, linked to the remotedevelop
branch:
$ git checkout -b develop origin/develop
- 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>
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
- Push a feature branch to the remote repository:
$ git svn dcommit [2]
- 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>
- 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>
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
- Push a release branch to the remote repository:
$ git svn dcommit [2]
- 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>
- 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]
- 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).