简体   繁体   中英

Patch forked repo with git

Say, I have a fork of some library ver. 1.1 under git. Then a new tar-ball ver. 1.2 comes out. How can I update my forked library to a new version?

You question isn't great, but I'll offer a potential solution.

Lets assume the code base for the library looks like this:

vendor  a -- b

you fork at b which is the 1.1 release.

vendor  a -- b
              \
               \
you             1 -- 2 -- 3

Now assuming development continues on the vendor tree.

vendor  a -- b -- c -- d
              \
               \
you (master)    1 -- 2 -- 3

and d becomes their 1.2 release. If the vendor tree is in a git repo and you can access it, then a git pull or maybe a git pull --rebase from the vendor tree should do most things you need, you may need to resolve some conflicts etc. However if the vendor tree is not in git, and the only access you have the source code is tarballs of each release then something slightly more complicated might be required.

So I would create a second branch at the point at which you forked, by doing:

$ git checkout -b v1.2 b

Then untar you v1.2 tarbar into this branch and commit the changes. You should now have something like this:

vendor  a -- b -- c -- d
             |\
             | \
you (master) |  1 -- 2 -- 3
              \
(v1.2 branch)  x

Now, either you can merge the changes from branch v1.2 using:

$ git checkout master
$ git merge v1.2

Or you can rebase your changes on top of v1.2 using:

$ git rebase v1.2

Which will give you:

vendor  a -- b -- c -- d
              \
               \
you (master)    x -- d -- 1 -- 2 -- 3

I'm no expert, so I'm sure people will comment if I've made some mistakes (please do, then I'll add corrections).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM