GIT-如何使分支与母版相同 [英] GIT - How to make a branch be the same as master

查看:64
本文介绍了GIT-如何使分支与母版相同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用git的网站

I have a website using git

安装程序具有master分支作为实时站点,而development分支作为dev域,用于在功能上线之前对其进行测试

The setup has the master branch as the live site and a develop branch as the dev domain which is used for testing features before they go live

从来没有直接在master或开发上完成任何工作,它总是在功能分支上完成,然后合并到开发中进行测试,然后由master上线

No work is ever done directly on master or develop, it's always done on feature branches and then merged in to develop for testing, followed by master to go live

我的问题是我有一个站点,其中有很多工作合并到了develop分支中,而该分支将永远不会上线

My issue is that I have one site which has had a lot of work merged in to the develop branch which is never going to go live

我被要求使developer分支与master分支匹配,以确保永远不会上线的工作不会影响对合并到开发中的其他新功能的测试

I've been asked to make the develop branch match the master branch to ensure the work that's never going live doesn't affect the testing of other new features that get merged in to develop

我已经做了一些研究,根据我的理解,我无法使用rebase,因为这更多的是使用分支之后提交的提交来更新分支

I've done a bit of research and from my understanding, I can't use rebase as that's more for updating a branch with commits made since you branched off

看来我需要做的唯一选择是重命名developer分支,然后从master分支重新创建它,并强制推送以对其进行远程更新

The only option that seems to do what I need is to rename the develop branch and then recreate it from master and force a push to update it remotely

这是我最好的选择吗?还是我不知道的另一种方式?也许重新设置是正确的,但是我不太了解它的用途?

Is this my best option? Or is there another way I don't know about? Or maybe rebase is correct but I'm not quite understanding its purpose?

预先感谢

推荐答案

如果您不关心保留开发内容,只需签出develop并将其重置为master.

If you don't care about preserving develop just checkout develop and reset it to master.

# make sure master is up to date before you do this
git checkout develop
git reset --hard master
git push -f # force push the branch

通常每天早晨在integration分支上执行此操作,因此夜间集成始终基于master.

This is often done for an integration branch every morning, so that the nightly integration is always based on master.

这篇关于GIT-如何使分支与母版相同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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