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?
I am somewhat surprised that the answers so far don't seem to take into account two things:
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.
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:
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With