Reputation: 1181
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?
Upvotes: 1
Views: 222
Reputation: 24174
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
Upvotes: 3