Jump to content

How to apply patch from one git repository to other one


Guest waza123

Recommended Posts

I have own repository branch, how to apply patch from different repository to my branch ?

For example:

Apply this patch

http://github.com/mangos/mangos/commit/2cb35a12ef35a489ddb0e561556c1e918d57f191

To my repository branch.

Something like:

git pull git://github.com/mangos/mangos.git 2cb35a12ef35a489ddb0e561556c1e918d57f191

With some git command (manually its hard)

Link to comment
Share on other sites

Figured out.. not very easy, but it's works nice.

// Create a link to repository

git remote add tmp git://github.com/[NAME]/mangos.git

// Fetch sources

git fetch tmp

// Create and switch to tmp branch

git checkout --track -b tmp tmp/master

// Switch back to your master branch which apply patch

git checkout master

// Now type the commit id which you want to get

git cherry-pick 1d7f6138bc1e2bc5ae40d264a48fbe2c5ec035cc

// Now push changes to your server

git push [REPOSITORY] master

// Delete tmp branch

git branch -d tmp

// Delete link to remote branch

git remote rm tmp

Link to comment
Share on other sites

If i'm not mistaken, there's no need to checkout a branch in order to cherry-pick from it, fetch should be enough.

You may also have a look at gitk, after fetching you can setup a view to the remote branch to get a history browser plus the ability to cherry-pick simply by right-clicking on commits.

Link to comment
Share on other sites

In ideal case, there would be something like

git fetch git://github.com/mangos/mangos.git 2cb35a12
git cherry-pick FETCH_HEAD

but, unfortunatelly, git won't eat it that easily.

However there's still noob-proof

git fetch git://github.com/mangos/mangos.git
git cherry-pick 2cb35a12

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use