简体   繁体   中英

How to do when I want to upgrade my project version using git (rebase or merge)?

Please forgive me if I didn't express it clearly in the title.

I have one project which is cloned from upstream. And now it is 1.5 in our branch without lots of our in house commits on it. Now the upstream will release 1.6, and we'd like to upgrade 1.6 too but keep our changes. In this case what should I do ? Thanks

There are many ways of doing it, but one of the simplest way is in below steps:

  1. Add upstream to your repo using below command:

git remote add upstream < upstream url >

  1. Then fetch your upstream to your local, with the below command

git fetch upstream

  1. Now create a local branch with the HEAD of your current branch, using below command:

git checkout -b new_branch

  1. Then choose the commit-id of upstream version 1.6, and start the rebase operation to update your new_branch to version 1.6.

git rebase --autosquash --interactive commit-id

It will play all your local patches to the upstream 1.6 version code. Resolve the conflicts and you have now a new_branch with version 1.6 along with your local changes.

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