简体   繁体   English

当我想使用git升级项目版本(变基或合并)时该怎么办?

[英]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. 现在,在我们的分支机构中它是1.5,而内部却没有大量提交。 Now the upstream will release 1.6, and we'd like to upgrade 1.6 too but keep our changes. 现在,上游将发布1.6,我们也想升级1.6,但保留我们的更改。 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 > git remote添加上游<上游网址>

  1. Then fetch your upstream to your local, with the below command 然后使用以下命令将上游获取到本地

git fetch upstream git从上游获取

  1. Now create a local branch with the HEAD of your current branch, using below command: 现在,使用以下命令使用当前分支的HEAD创建一个本地分支:

git checkout -b new_branch 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. 然后,选择上游版本1.6的提交ID,然后启动rebase操作以将new_branch更新为版本1.6。

git rebase --autosquash --interactive commit-id git rebase --autosquash-交互式提交ID

It will play all your local patches to the upstream 1.6 version code. 它将播放所有本地补丁到上游1.6版本代码。 Resolve the conflicts and you have now a new_branch with version 1.6 along with your local changes. 解决了冲突,您现在有了一个带有版本1.6的new_branch以及本地更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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