git flow - how do I pause development on one feature to work on another

GitGit Flow

Git Problem Overview


I'm new to git and git flow. I've read all the various pages, blogs, and stackoverflow questions on it,and have been using it in my daily development.

But one issue has been bothering me, I just can't wrap my head around it. I know feature branches are supposed to be small, you start a feature, code a part of it, then finish the feature. This is a daily occurence, I get that. We just make sure that our develop branch is always buildable.

But what happens when I'm in the middle of a feature, it isn't ready to be finished, but work priorities change? I'd like to be able to switch to another feature.

For example, I start a new feature.

$ git flow feature start yak-Speedup

I write code, commit files, etc... and am making good progress on it. But now I need to change what I am working on, mostly like because I need a resource that isn't available and the server coder won't have it ready for a day or two. I can't finish the feature because it will break the develop branch.

I'd like to do something like this:

$ git flow feature pause yak-Speedup
$ git flow feature start alpaca-Sheering
#write code
$ git flow feature finish alpaca-Sheering
$ git flow feature resume yak-Speedup

Indeed, the existence of the "git flow feature list" command implies that I can have several features going at the same time. But I don't see how to create or switch between features. Indeed, I'm starting to think that this isn't a git flow issue at all, but a git issue.

I appreciate any help. Thanks!

Git Solutions


Solution 1 - Git

You do not need the git flow feature pause yak-Speedup command (feature pause doesn't exist anyway). The command you want to use in place of git flow feature resume yak-Speedup is git flow feature checkout yak-Speedup; that will get you back on the yak-Speedup feature branch to continue development.

Executing git flow displays:

Try 'git flow <subcommand> help' for details.

And executing git flow feature help displays:

usage: git flow feature [list] [-v]
       git flow feature start [-F] <name> [<base>]
       git flow feature finish [-rFk] <name|nameprefix>
       git flow feature publish <name>
       git flow feature track <name>
       git flow feature diff [<name|nameprefix>]
       git flow feature rebase [-i] [<name|nameprefix>]
       git flow feature checkout [<name|nameprefix>]
       git flow feature pull <remote> [<name>]

Solution 2 - Git

Late to the party, but my experience is this..I use git in combination with git flow..

git flow feature start foo  <<== start
#code, hack and COMMIT
git checkout develop        <<== go back to develop branch.. 
git flow feature start foo2 <<== start a new feature
#code, hack and COMMIT
git checkout feature/foo    <<== go back to foo. NB: using full branch name

By going back to develop i ensure that I am branching independently from foo and using develop only. I can also do any merging of develop if there has been commits from other features at the time as well....

Solution 3 - Git

What you want are really branches:

git branch feature1 <startingpoint>
git checkout feature1
# hack hack hack, commit commit commit
git branch feature2 <startingpoint>
git checkout feature2
# hack hack hack, commit commit commit
# Oops, urgent request comming in, must switch to stable and patch
git stash
git checkout stable
# patch, commit, push
# back to feature2
git checkout feature2
git stash pop

etc etc. Branches are made for that.

And once you know your feature is good, merge into dev and push.

Solution 4 - Git

Use a more explicit model. This is git flow improved with no extra commands:

https://plus.google.com/109096274754593704906/posts/R4qkeyRadLR

The important thing here is that you would not start feature2 off of feature1.

Hope this helps.

UPDATE

I've blogged about this. Hope it's a little clearer:

http://dymitruk.com/blog/2012/02/05/branch-per-feature/

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJohn GreenView Question on Stackoverflow
Solution 1 - GitDan CruzView Answer on Stackoverflow
Solution 2 - GitangryITguyView Answer on Stackoverflow
Solution 3 - GitfgeView Answer on Stackoverflow
Solution 4 - GitAdam DymitrukView Answer on Stackoverflow