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

查看:188
本文介绍了在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



<成为这个

to become this

                          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
)

但是以

But you will end up with

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天全站免登陆