Git merge a single file without rebooting

I have three branches (let me call them master, testing and function). All three are shared, so I cannot reinstall any of them without causing problems for the others. Currently, all three branches are diverging (none of them is fast forward), so ultimately some merging will be required, since rebooting is not an option.

At the moment, I would like to extract the Makefile from testing into a function, since the function was disconnected from the wizard, and the Makefile was added to the testing. However, I do not want to merge into any other changes between the two branches.

I understand that if I just git-add the Makefile will function, it will cause merge conflicts when I merge the function again into testing (and then the wizard), especially if I make any additional additions to the Makefile in my function branch.

I could do git -cherry-pick; however, there have been many Makefile attempts in testing, and I assume that there is a better way than trying to use cherries - all these commits to a function.

+7
source share
1 answer

You can just do

git checkout branch_name <path(s)>

This may load a specific file, but you can also use wildcards and directories

Note that:

  • Relative paths
  • The path does that git does not switch branches, so you can just commit after gettihg file
+12
source

All Articles