How to merge hot fix on branch to master
git
Solution
To make a history that reflects reality and so save yourself potential trouble downstream,
git checkout -b Jbranch B
git cherry-pick J
git checkout -B branch I
git merge Jbranch
git checkout -B master G
git merge Jbranch
git branch -d Jbranch
Producing
A..B..C..D..F..G..J'' master
| /
|\........J'.+
| \
\....E..H..I..J branch
The 'J' commit's tree in the old and new 'branch' tip will be identical, just with the explicit history this time.
Problem
If I start with a structure like follows on my remote: ``` A-B-C-D-F-G master \ E-H-I branch ``` And I clone branch and make change 'J' (& commit and push to remote branch) how can I merge 'J' to master without bringing down 'H' and 'I'? Can it be done just by pushing change 'J' or do I need to switch to a local repo tracking master and merge the local 'J' change and push that to master? ``` A-B-C-D-F-G-J master \ E-H-I-J branch ```