1

For example, I'm dealing with feature branch, another developer pushed just right now to origin/develop his latest fix, and I have to use (add) his fix in my feature branch.

how I should do it ?

git checkout -b my-feature-branch
... dealing with my issue ...
... alarm! another developer just released his fix, I need it here in my feature branch ...
git stash
git checkout develop
git pull origin develop
git rebase my-feature-branch develop
git checkout my-feature-branch
git merge develop
git stash apply
... dealing with my issue ...
git commit
git checkout develop
git merge my-feature-develop
git push origin develop

Is it correct behaviour ?

In that case very hard to figure out where my branch was started and where were finished. And second point I'm doing rebase for public branch (develop) and it's not good, right ?

What the proper way to update (refresh) working branch with new info ?

user1016265
  • 2,307
  • 3
  • 32
  • 49

2 Answers2

0

Find the commit(s) of the hotfix, then cherry-pick it/them.

Fred Foo
  • 355,277
  • 75
  • 744
  • 836
0

This seems wrong: git rebase my-feature-branch develop

It should be:

git rebase develop my-feature-branch`

What you need to do is rebase what you already done in my-feature-branch on top of the now updated develop branch.
No need to merge develop in my-feature-branch.

The full sequence would then looks like

git checkout -b my-feature-branch
... dealing with my issue ...
... alarm! another developer just released his fix, I need it here in my feature branch ...
git stash
git checkout develop
git pull origin develop

# remember that such a rebase will starts with a
# git checkout my-feature-branch
git rebase develop my-feature-branch
git stash apply
... dealing with my issue ...
git commit
git checkout develop
git merge my-feature-develop
git push origin develop
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Could you please clarify these two lines ? # remember that such a rebase will starts with a # git checkout my-feature-branch – user1016265 Apr 01 '13 at 13:27
  • 1
    @user1016265 from [`git rebase` man page](http://git-scm.com/docs/git-rebase): `git rebase [] []`: If `` is specified, `git rebase` will perform an automatic `git checkout ` before doing anything else. Otherwise it remains on the current branch. In your case, no need to checkout `my-feature-branch` after having rebased it on top of `develop`: the rebase will have first checked out `my-feature-branch`, so at the end of the rebase, your current branch will be `my-feature-branch`. – VonC Apr 01 '13 at 14:09
  • thanks for explanation. What if I did like I described in the beginning, should I fix something ? or everything will be ok ? – user1016265 Apr 01 '13 at 14:12
  • @user1016265 the beginning is fine until the rebase: you shouldn't rebase develop on top of `my-feature-branch`. Did you already do that? – VonC Apr 01 '13 at 14:14
  • @user1016265 then you can force develop branch back to where it where with the reflog: http://stackoverflow.com/questions/134882/undoing-a-git-rebase/135614#135614, and then resume with the right rebase. – VonC Apr 01 '13 at 18:42