1

I have next scheme:

 master --> dev -->  final --> prod
         ____________|^ ^
        |             | |____________________________
        |             |_______                       |
        |                     |                      |
   next version --> dev --> bug fixed --> dev --> bug fixed --> .....

As you can see from this scheme, we have finished and deployed the master branch to production. Then we have started new version of the project and did another branch. During the dev process we find some bugs and have to fixed it for both branches.

Previously I did it manually thru comperesing window in my editor and my algorithm was next:

(current branch "new version")
git add .
git commit -m "fixed bug"
git push
git checkout master
(put fixes manually)
git add .
git commit -m "fixed bug"
git push

But the last fix is touching multiple as js as html files.

From some researches in internet I have found 2 options:

 1. git merge - as I could understand it will be full merging between both branches

 2. git rebase - I think this is what I'm looking for but I'm not sure that this is exactly what I need.

So can anybody help me with my doubts?

1
  • 1
    You can use cherry-pick here
    – Mr. Alien
    Commented Mar 15, 2017 at 18:27

1 Answer 1

3

You can take the last commit from new-version to master by cherry-pick.

Fix the bug in new-version branch.

$ git checkout new-version
$ git add .
$ git commit -m "Fixed bug"
$ git push 

$ git log                     # copy the 'commit-hash' of last commit ("Fixed bug")

Now go to master branch and cherry-pick the commit.

$ git checkout master
$ git cherry-pick <commit-hash>
$ git push 
2
  • Hooray, this exactly what I was looking for!! thanks!
    – antonyboom
    Commented Mar 15, 2017 at 18:37
  • Note that you can also git cherry-pick branch-name Commented Mar 15, 2017 at 18:50

Not the answer you're looking for? Browse other questions tagged or ask your own question.