git-flow: how to checkout release branch from origin?

22,279

Solution 1

All that is needed is setting up a local tracking branch, no git-flow specific commands are needed. Git-flow apparently only cares about the name of the branch and if it is prefixed with the "release/" string.

So setting up a local tracking branch like git branch --track release/1.5 origin/release/1.5 is all there is to it.

Solution 2

git flow release (and feature) have a "track" command to simplify what you're trying to do. To set up a local tracking branch for a branch that has already been published, and switch to it, just do this:

git flow release track 1.0

or

git flow feature track my-feature-branch

Here's the code excerpt from the gitflow source for the release "track" command:

cmd_track() {
    parse_args "$@"
    require_version_arg

    # sanity checks
    require_clean_working_tree
    require_branch_absent "$BRANCH"
    git_do fetch -q "$ORIGIN"
    require_branch "$ORIGIN/$BRANCH"

    # create tracking branch
    git_do checkout -b "$BRANCH" "$ORIGIN/$BRANCH"

    echo
    echo "Summary of actions:"
    echo "- A new remote tracking branch '$BRANCH' was created"
    echo "- You are now on branch '$BRANCH'"
    echo
}

Helpful git flow command line arguments

Solution 3

Once git flow release publish is done, you can do the following:

git fetch -q “origin” “release1.0”
git branch –no-track “release1.0” FETCH_HEAD
git checkout -q “release1.0”

And then you can start pulling:

git pull “origin” “release1.0”
Share:
22,279
ChrisR
Author by

ChrisR

Zend Certified PHP Engineer and Certified Scrum master with over 15 years of professional web application development experience working with small, large, local and offshore teams. Experienced with frameworks like Zend Framework, Silex and Symfony and self built frameworks for specific application development. Building and maintaining complex software, working with legacy code and building a RESTful webservices from the ground up according to the real restful principles. Fond interest and knowledge of modern front-end applications/frameworks like AngularJS and React along with the frontend eco system. Likes working with people, building teams and helping them improve.

Updated on November 23, 2020

Comments

  • ChrisR
    ChrisR over 3 years

    What is the perferred workflow to pull a published release branch from the central repo using git-flow?

    eg:
    Mike made a release branch, he published it through "git flow release publish 1.0"
    Jane would like to work on that release branch too, how does she pull it from the central repo to continue working with git flow on that particular branch?

    • create the branch herself locally through git flow release start 1.0 and then git pull?
    • create a tracking branch locally through git with git checkout -b release/1.0 origin/release/1.0 and continue from there (does git flow work on the branch this way?)