An efficient workflow for working with git flow


Setup git

You need to do this only once for your user account on a specific computer.

See also ...

git config --global branch.autosetuprebase always

Setup the current project for use with git flow

yes "\n" | git flow init
git branch -u origin/develop develop

Development workflow

Working on a branch

create a new feature branch

In the following example we will create a branch for fixing the issue #2778.

you can either use git flow for creating a new branch.

git flow feature start #2778

or use git directly:

git checkout -b #2778

The only difference of both is that git flow will create a branch with the prefix @feature/@.

For minor changes that only require one single commit you can in principle also directly work on the develop branch.

Committing your work

review the changes you made so far

show the list of modified, new and deleted files

git status

eGit: open the Git Staging view

review the modification in the files:

unstaged files (whitespace changes ignored):

git diff -w

stages files (whitespace changes ignored):

git diff -w --cached 

eGit: double click the files in Unstaged Changes, Stages Changes

stage files in the index

stage all files also new and remove deleted ones

git  add -A .

stage specific files

git add {file}

interactive staging

git add --interactive

eGit: right click on the fiels in Unstaged Changes

commit the staged changes to the local git repo

git commit -m "commit message"

eGit: click Commit

WARNING: do NOT click on Commit and Push except you have a specific reason to do so!

finish a feature

finishing a feature should involve two steps:

  1. check for upstream changes in develop and update your local clone. This effectively avoids merge conflicts and helps creating a clean history.

  2. merge the feature branch into the develop branch

*1. check for upstream changes in develop *

Fetch the latest changes from the remote and review the changes that came in.

git fetch
gitk --all &

eGit: open the Synchronize view ????

In case of new commits that are in the remote repository you will receive a notification that your branch is behind. In this case you will execute

git checkout develop
git pull

NOTE: if git complains about ... you need to set the upstream branch for develop

eGit: There are several ways to checkout a local branch, see User_Guide > Checking_out_an_existing_Branch ... to be elaborated

  • 2. merge the feature branch into the develop branch*
git flow feature finish

now you should be in any case in the branch develop.

The last thing to do is to push the changes to the remote

git push

Updated by Andreas Müller over 6 years ago · 14 revisions