Learn git-flow in 5 steps

with the flavour of Git

Steps

  1. Install
  2. Init
  3. Branches
  4. Create
  5. Remove

Extra

  • Useful commands
  • Conventions
  • Rules

Install

1.

MacOS X

Windows

$ brew install git-flow
$ wget -q -O - --no-check-certificate https://raw.github.com/petervanderdoes/gitflow-avh/develop/contrib/gitflow-installer.sh install stable | bash

You need Homebrew installed

You need Cygwin installed (wget and util-linux)

Init

2.

Start a new repository

$ git flow init
Initialized empty Git repository in ~/project/.git/
No branches exist yet. Base branches must be created now.
Branch name for production releases: [master]
Branch name for "next release" development: [develop]

How to name your supporting branch prefixes?
Feature branches? [feature/]
Release branches? [release/]
Hotfix branches? [hotfix/]
Support branches? [support/]
Version tag prefix? []
$ git flow init

It should ask some questions

Where we are now?

It moved us to develop branch

But do not worry, we are going to see all branches types in a moment 

Branches

3.

We have 2 types of branches: main and temporary

WTF means that?

Which are the main difference between main and temporary?

their job

We have three main:

release, develop and master

Develop comes from master

But release comes from develop

And two temporary:

hotfix and feature

Feature comes from develop

Instead, hotfix comes from master

Create

4.

# For feature and hotfix
$ git flow [feature | hotfix] start [branch-name]
  
# For release only
$ git flow release start [release-number]

We use start for tell git-flow that we want a new branch of the specified type

Remove

5.

We use finish for tell git-flow that we finished the job in that branch

# For feature and hotfix
$ git flow [feature | hotfix] finish [branch-name]
  
# For release only
$ git flow release finish [release-number]

Extras

A good commit is:

  • One logical change
  • Have issue / bug number attached ( if have )
  • Use human language
  • No more than 50 characters for commit
  • Good description ( if it is needed for explain what is inside )

Like this

We have awesome commands from git

Like git stash

# Returns to a clean working directory
$ git stash

# List all
$ git stash list

# Delete one ( the stash in pos 0 )
$ git stash drop stash@{0}

# Delete last and get it back
$ git stash pop

# Reply the same status as it was ( unstaged and ready )
$ git stash apply

# Remove all saved
$ git stash clear

For save our uncommited changes and change to another branch without uploading anything

# Change the last commit message
$ git commit --amend

# We can change the files too if we
# edit the files and call the command

Or commit

with special flags

# We can search a commit by it's content
$ git show ":/fix"

# This will show us all the commits which contains "fix"

Or show

For search for a commit content

Go and try yourself!

After this presentation...

How-to start with Git and GitFlow

By Amanda Copete

How-to start with Git and GitFlow

Git and gitflow short course for newbies

  • 1,018