Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to manage the open source projects patches which can't push to upstream?

I'm working on a open source project. Now I finished a few patches which are relevant to the company business and I can't push these patches to upstream.

So I have to keep these patches on my local git repository. I have to pull the new patches from upstream and resolve the conflicts with my patches.

Anyone have my similar experience and how to work with it comfortably?

Update: Just like if I have several patches can't be accept by Linux Kernel because these patches are unfriendly to the kernel. I have to do daily kernel building and I don't want to type by hand everyday. Is there exists any tools to help me?

like image 519
wang wynn Avatar asked Jul 13 '13 14:07

wang wynn


3 Answers

I am somewhat surprised that the answers so far don't seem to take into account two things:

  1. Not all modifications done by programmers is intended for or suitable for submission to an open source project.
  2. Even when it is, if there is an update to the repository while your working on your code, you very often want to merge those changes into your working copy.

The good thing is that since you are working with a decent version control software is not usually that difficult to do what you need. I'm a subversion guy (due to company policy) so I don't specifically know about GIT but after reading this wiki article, it seems pretty much the same deal. You don't have to apply the patches again as long as you fit the files in your local repository. You can update the local copy with the patches already applied!

Your custom code probably touches a very small fraction of the repository code. It's likely that most changes in the repository will not touch the same code you've touched. You will simply need to use the git pull command to download all the updated code. When the sections you have touched are changed on the repository, git will do it's best to merge those changes. The only time you have to hand edit files is she git detects a conflict that it can't resolve. The article I mentioned, earlier talks about this.

You may use your favorite text editor but actually it is quite convenient to use a 3-way merge tool in this case. Meld is one such tool for Linux but I'm sure there are many out there.

like image 50
Benjamin Leinweber Avatar answered Nov 15 '22 01:11

Benjamin Leinweber


Here is a possible workflow.

Initial setup

git clone --origin 'upstream' http://example.com/project.git
cd project
git checkout master
git checkout -b patched
# make changes
git add --all
git commit -m 'internal patches'

New upstream changes

git checkout master
git pull upstream
git checkout patched
git rebase master

References:

  • rolf@Supenta: Git: How to consistently maintain local patches
  • Maintaining a local patch set with git - Tony Finch
like image 33
go2null Avatar answered Nov 15 '22 03:11

go2null


Firstly before making changes to the project-

  1. create a branch
  2. Change to that branch for any changes you make
  3. To pull the new patches from the upstream revert back to the master branch and then git pull.

The commands to create the branch and change are as follows

1. $ git branch <branch name>           // To create a new branch
2. $ git checkout <branch name>         // To change to the branch
3. $ git checkout master                // To change to the master branch
like image 1
Santosh A Avatar answered Nov 15 '22 02:11

Santosh A