Early this year I wrote a post about Git Command that I think are handy to know: Git commands I keep forgetting
After working with Git more and more I have gathered some other command as well that I would like to share with you:
Update the local develop branch while working on a feature branch
We use git flow from nvie a lot. Which is very nice because it handles a lot of stuff for you. But one thing that I did not like was when I wanted to finish the feature using:
$ git flow feature finish FEATURE-NAME
I first had to update the develop branch because otherwise it will merge with an old version of develop. Steps that I had to follow where:
# switch to develop
$ git checkout develop
# update develop
$ git pull
# switch to feature branch
$ git checkout feature/FEATURE-NAME
# merge from develop to feature branch
$ git merge develop
# finish feature
$ git flow feature finish FEATURE-NAME
# push changes
$ git push
It is also possible to merge from origin/develop to your feature branch, but still if you want to finish the feature branch you have to make sure that the local develop branch is up to date.
With the following command you can eliminate the first 3 commands:
# update develop branch without checkout
$ git fetch origin develop:develop
So if the feature branch is not up to date with develop the flow becomes the following:
# update develop
$ git fetch origin develop:develop
# merge from develop to feature branch
$ git merge develop
# finish feature
$ git flow feature finish FEATURE-NAME
# push changes
$ git push