Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use Git to apply update patches to customized software?

Tags:

git

On one of my websites I have installed forum software (PunBB). Because the software doesn't offer any hooks or filters I have over time added customizations to the core. This means that updating to newer versions becomes more and more cumbersome, because I have to do everything manually.

I have never used Git before, but I've read about it. Most of the use cases start from a clean code base and use Git to track changes, but I have to start from code that has been changed extensively, and add patches to that. I haven't been able to find a way to use Git in my situation and I'd really like to know if this can be done.

like image 454
ArchCarrier Avatar asked Dec 23 '13 11:12

ArchCarrier


1 Answers

Yes you can, and absolutely should.

  • Clone original repository from native source (in your case git clone https://github.com/punbb/punbb)
  • Create your local branch starting from upstream master branch.
  • Create difference between upstream master and your customized copy and commit it into your branch.
  • Continue committing your customizations into local branch, and from time to time merge (or sometimes just cherry-pick) from upstream master branch.
  • Consider contributing back some of your work - it will make merging easier, eventually.

EDIT: expanded step 3 by your request:

  1. After cloning upstream repository, create your local development branch (say, mybranch) based on upstream master currrent state:

    git branch mybranch origin/master
    git checkout mybranch
    
  2. Edit files in this branch to reflect your local patches. However, you want this difference to be as small as possible - don't just blindly replace all files, spend some time thinking if you can stay closer to upstream.

  3. Commit this difference into your mybranch.

  4. From time to time, fetch new commits to master from upstream:

    git fetch origin
    

    and merge those changes into your mybranch (assuming that you are on it, if not, checkout to mybranch it first):

    git merge origin/master
    
like image 99
mvp Avatar answered Sep 30 '22 04:09

mvp