Git远程分支已删除,如何与新分支重新同步本地更改 [英] Git remote branch got deleted, how to resync local changes with new branch

查看:572
本文介绍了Git远程分支已删除,如何与新分支重新同步本地更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一个名为 develop_1 的远程分支.我所有的本地代码更改都已提交给我,但是我的领导不小心删除了该远程分支.

I got a remote branch as develop_1 which I was using. All my local code changes were committed to it but my lead has accidentally deleted that remote branch.

我在本地系统中进行了所有这些代码更改.现在,我想将所有更改推回到新的远程分支中的同一Git存储库中,例如 develop_2 .

I have all those code changes in my local system. Now I want to push all those changes back to that same Git repository in a new remote branch, say develop_2.

如何创建新分支,同步本地更改并将其推送到远程?

How can I create a new branch, sync my local changes and push it to remote?

推荐答案

在您的本地分支 develop_1 中,您可以简单地创建新分支:

Within your local branch develop_1 you could simply create the new branch:

$ git checkout -b develop_2

推送您的更改,然后通过运行以下命令来保持本地仓库同步:

Push your changes and then to keep your local repo in sync by running:

$ git fetch -p

-p用于prune删除本地分支,在这种情况下,是远程不再存在的旧 develop_1 .

The -p is for prune deleting local branches, in this case, the old develop_1 that don't exist in the remote anymore.

这篇关于Git远程分支已删除,如何与新分支重新同步本地更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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