secondman
secondman

Reputation: 3277

How to patch a repo in GIT

I've forked a repo at GitHub for OpenCart, and it contains several branches

master
development-feature-profiles
v1.5.5.1
v1.5.5.2
v1.5.6
v1.5.6.1

The current master branch has all the changes in it for the upcoming version 2.0.

I've created my own branch, based on the master branch, let's call it:

development-2

It has a bunch of changes I've made to the core files etc. I'm not interested in doing a pull-request to opencart for these changes, or more accurately, they're not interested in merging my changes, so that's fine.

I'm leaving the master branch as is and pulling their updates into it.

My question is, how can I merge the new changes from the master that come as they continue to update the opencart/opencart repo that I've forked into my development branch, without overwriting my changes?

I assume that I have to create some sort of diff and patch but I'm unclear on how and I can't fine any instructions online.

Upvotes: 2

Views: 87

Answers (1)

silvio
silvio

Reputation: 2294

If you share your development-2, you should merge the master in your development-2. Your history looks then like this:

                     *- [patch to make development-2 compatible to new master]
:                    :
|,-------------------*- merge
|                    |
:- [some work ...]   :- [some work ...]
|                    |
|,-------------------*- merge
|                    |
:- [some work ...]   :- [some work ...]
|                    |
*- master            *- development-2 
:                    :

If you dont share your code or you don´t care other developers repository you can use a git pull --rebase. Maybe you have to add one patch in development-2 to make the branch compatible to the new master.

Then the history looks like this:

                     *- development-2
                     :- [some work]
                     *
 ,-------------------*
*- master

if master is updated and you use git pull --rebase than it looks like so

                     *- [patch to make development-2 compatible to new master]
                     *- development-2
                     :- [some work]
                     *
 ,-------------------*
*- master
*
:- [some work ...]
*- [old master]

Upvotes: 1

Related Questions