Skip to content

Instantly share code, notes, and snippets.

@alexanderjeurissen
Last active April 11, 2016 19:37
Show Gist options
  • Save alexanderjeurissen/8399988 to your computer and use it in GitHub Desktop.
Save alexanderjeurissen/8399988 to your computer and use it in GitHub Desktop.
Git flow test

#Git-flow tutorial

by Alexander Jeurissen

I created a test repository on Github to check if git-flow can aid in keeping a clean branch model. In the steps below you can see how I create a new feature and release containing our new feature.

  1. Create remote repository on Github

  2. Clone de remote repo with git clone

  3. Init git flow with defaults: git flow init -d

    result:

    Using default branch names.

    Which branch should be used for bringing forth production releases?

    • master Branch name for production releases: [master]
  4. When the previous command is finished the develop branch is automatically created and checked out. all I have to do is push the new branch, so it's also available on Github. git push origin develop

  5. Create new feature with git flow: git flow feature start cats

    result:

    Switched to a new branch 'feature/cats'

    Summary of actions:

    • A new branch 'feature/cats' was created, based on 'develop'
    • You are now on branch 'feature/cats'

    Now, start committing on your feature. When done, use:

    git flow feature finish cats

  6. Publish feature to Github git flow feature publish cats

    result:

    Total 0 (delta 0), reused 0 (delta 0)

    To https://github.com/alexanderjeurissen/gitFlowTest.git

    • [new branch] feature/cats -> feature/cats

    Already on 'feature/cats'

    Summary of actions:

    • A new remote branch 'feature/cats' was created
    • The local branch 'feature/cats' was configured to track the remote branch
    • You are now on branch 'feature/cats'
  7. Create txt file named cats.txt touch cats.txt

  8. Start tracking cats.txt git add cats.txt

  9. Commit cats.txt to feature branch git commit -m "add cats"

  10. I'm finished with this feature to close this feature i can use the following command: git flow feature finish cats

    result:

    Switched to branch 'develop'

    Updating 00ebac7..062549e

    Fast-forward

    cats.txt | 0

    1 file changed, 0 insertions(+), 0 deletions(-)

    create mode 100644 cats.txt

    warning: not deleting branch 'feature/cats' that is not yet merged to 'refs/remotes/origin/feature/cats', even though it is merged to HEAD.

    error: The branch 'feature/cats' is not fully merged.

    If you are sure you want to delete it, run 'git branch -D feature/cats'.

    Summary of actions:

    • The feature branch 'feature/cats' was merged into 'develop'
    • Feature branch 'feature/cats' has been removed
    • You are now on branch 'develop'
  11. As you can see git-flow checked out the develop branch it then merged the feature/cats branch into 'develop' and tried to remove the feature branch. However it aborted finishing the feature because the feature isn't committed to Github yet.

  12. first i need to push the feature branch with git push origin feature/cats

    result:

    counting objects: 4, done.

    Delta compression using up to 4 threads.

    Compressing objects: 100% (2/2), done.

    Writing objects: 100% (3/3), 282 bytes | 0 bytes/s, done.

    Total 3 (delta 0), reused 0 (delta 0)

    To https://github.com/alexanderjeurissen/gitFlowTest.git

    00ebac7..062549e feature/cats -> feature/cats

  13. now i need to checkout the feature branch and finish it with: git flow feature finish cats

    result:

    Switched to branch 'develop' Already up-to-date. Deleted branch feature/cats (was 062549e).

    Summary of actions:

    • The feature branch 'feature/cats' was merged into 'develop'
    • Feature branch 'feature/cats' has been removed
    • You are now on branch 'develop'
  14. I think it's time for a new release, to start a release i use: git flow release start 1.0

    result:

    Switched to a new branch 'release/1.0'

    Summary of actions:

    • A new branch 'release/1.0' was created, based on 'develop'
    • You are now on branch 'release/1.0'

    Follow-up actions:

    • Bump the version number now!
    • Start committing last-minute fixes in preparing your release
    • When done, run:

    git flow release finish '1.0'

  15. There are no last-minute fixes so let's finish the release with : git flow release finish 1.0 this asks me for both a merge commit message and a tag commit message.

    result:

    Switched to branch 'master'

    Merge made by the 'recursive' strategy.

    cats.txt | 0

    1 file changed, 0 insertions(+), 0 deletions(-)

    create mode 100644 cats.txt

    Deleted branch release/1.0 (was 062549e).

    Summary of actions:

    • Latest objects have been fetched from 'origin'
    • Release branch has been merged into 'master'
    • The release was tagged '1.0'
    • Release branch has been back-merged into 'develop'
    • Release branch 'release/1.0' has been deleted
  16. And it's done our release is a fact. if i run git branch now only the master and develop branch are left.

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