0

I want to move a project into git that consists of a bunch of code supplied by a vendor, with some customizations on top of that code (added files and modified files).

I have a vendor branch that has all the code, and I store just the customizations in master. Now I'm looking at how to pull all that code down to construct the whole project by adding both vendor and master as remotes but git fetch --all doesn't seem to do it...it skipped any folders that were not in master.

Am I going about this the wrong way? Is this not possible?

Don Zacharias
  • 1,544
  • 2
  • 14
  • 31

2 Answers2

0

No, what you are trying will not work with git. Branches are meant to be separate.

git fetch only updates it's internal knowledge about it's remotes, it never changes the files you see. fetch --all means "fetch from all remotes", such as when you follow changes from multiple github repositories.

You can only merge the two branches to get the result you want. You can use an additional temporary branch as an example, like:

git checkout vendor --branch my-temp-branch
git merge master

That way vendor and master branches will stay the same, and my-temp-branch will have the files from both branches.

Other alternatives:

tkruse
  • 10,222
  • 7
  • 53
  • 80
  • Thanks. I thought about it a little and I think possibly I could avoid versioning the vendor's code in my project (any files that I haven't touched) and just figure out the merge as part of build. When the vendor updates their code I might just have to manually diff and update the files in my project. I think I just need to wrap my head around remotes in general--I think it's one of the trickier concepts when moving from Subversion as I am doing. – Don Zacharias May 15 '19 at 01:59
  • Maybe if you describe your setup in subversion in the question, a better answer can be found. Do you use different subversion branches for the same problem? It might also help to know a little more about the setup, like the file structure of the vendor code and the build process. Also see new linked answer from https://stackoverflow.com/questions/2048470 – tkruse May 15 '19 at 04:05
0

if you do want to merge the whole branch and just want merge changes of specific commit you can use cherry pick to do that. https://git-scm.com/docs/git-cherry-pick

Ahmed Waqas
  • 245
  • 1
  • 3
  • 14