在git中更改分支的根 [英] Change root of a branch in git

查看:38
本文介绍了在git中更改分支的根的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 git 并想更改现有分支的基础.这是由部署系统引起的,该系统将此显式分支拉入我的生产环境.在计划我的发布时,我每次想要上线时都会创建一个标签.但是我的分支也有特殊的变化,所以 git reset --hard v1.0 不起作用.

I'm using git and want to change the base of an exiting branch. This is caused by a deployment system, which pulls this explicit branch into my production environment. When planning my releases, I create a tag every time I want to go live. But my branch has special changes too, so git reset --hard v1.0 won't work.

这里是一个小例子.我想要这个

Here a small example. I want this

      C---D---E deploy
     /
A---B---F---G master
     
      v1.0

变成这样

                          C---D---E deploy
                         /
A---B---F---G---H---I---J---K master
                        
      v1.0                v1.1

也许 git rebase 是我正在寻找的,但手册页对我没有帮助.感谢您的回复!

Maybe git rebase is what I am looking for, but the man pages don't help me. Thanks for your replies!

推荐答案

git rebase 应该如您所说,允许您更改部署的基础:

git rebase should, like you say, allow you to change the base of deploy:

git checkout deploy
git rebase v1.1 # using the tag
(or:
 git rebase J # SHA1 of J
 or
 git rebase master~1
)

但你最终会得到

C'---D'---E' deploy

也就是说,deploy 分支的提交部分的 SHA1 被重写,如果没有人克隆所说的 deploy 分支并正在处理它,这还不错.
由于它是用于部署的分支,因此很可能是这种情况(即没有人在处理所述分支的克隆).

That is, the SHA1 of the commits part of deploy branch are rewritten, which isn't too bad if nobody cloned said deploy branch and was working on it.
Since it is a branch for deployment, that is most likely the case (i.e. nobody was working on a clone of said branch).

这篇关于在git中更改分支的根的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆