In Git, how to merge (not checkout) part of files from a long ago branch -


like fig.a, release-1.0 delivered customer long long ago, huge bug found recently, , hotfix made in release-1.1 , re-delivered.

now merge only bugfix files (about 10 files) release-1.1 branch master in fig.b way, is, release-1.1 must parent-node of master in git history. git checkout release-1.1 <file> way not match purpose.

meanwhile, since c2 far master, there many different files (nearly hundreds files can not merge automatically), , work of canceling these merge conflicts may kill me....

so how realize purpose in git? sorry poor english , poor git skills. ^_^

fig a:

    release-1.0 <--- release-1.1                                   |                                                                       v                                                            c1 <--- c2 <--- c3 <--- c4 <--- c5 <--- c6 <--- master 

fig b:

    release-1.0 <--- release-1.1 <----------------------\         |                                               |                v                                               |        c1 <--- c2 <--- c3 <--- c4 <--- c5 <--- c6 <--- c7 <--- master 

i don't see way around dealing potential merge conflicts, because hotfix made on older version of branch.

one option cherry-pick hotfix commit, , choose version of files latest master branch files except 10 files involved in hotfix:

git checkout master git cherry-pick <sha-1 release-1.1> 

where <sha-1 release 1.1> sha-1 hash of hotfix commit in release-1.1 branch. keep in mind may conflicts in 10 hotfix files themselves. in case, should focus on hotfix changes, tending choose latest master version in other cases.


Comments