How to merge specific files from Git branches -
i have 2 git branches branch1 , branch2 , want merge file.py in branch2 file.py in branch1 , file.
in essence want work on file.py in branch1 want take advantage of merge command. best way this?
the accepted answer mentions using git checkout
. now, there content in file.py
branch2
no longer applicable in branch1
. such situation require picking changes , leaving others. therefore, have full control interactive merge using --patch
switch:
$ git checkout --patch branch2 file.py
the interactive mode section in man page git-add(1)
explains keys used:
y - stage hunk n - not stage hunk q - quit; not stage hunk nor of remaining ones - stage hunk , later hunks in file d - not stage hunk nor of later hunks in file g - select hunk go / - search hunk matching given regex j - leave hunk undecided, see next undecided hunk j - leave hunk undecided, see next hunk k - leave hunk undecided, see previous undecided hunk k - leave hunk undecided, see previous hunk s - split current hunk smaller hunks e - manually edit current hunk ? - print
the split command particularly useful.
Comments
Post a Comment