git删除并重新创建分支 [英] git delete and recreate branch

查看:920
本文介绍了git删除并重新创建分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

摘要:重现错误


  • 创建一个分支并将其检出

  • let其他人删除它并创建一个具有相同名称的新分支
  • 现在执行 git分支-D <分支> git checkout -b< branch> --track origin /< branch>

  • git pull 上获得! [已拒绝]<分支> - >起源/<分支> (非快进)



要修复它,您必须删除远程跟踪信息 git branch -d -r origin /< branch> 以及

$ hr

OLD:有人删除了开发分支,并创建它以删除所有功能分支,并再次将主分支作为基础。然后他添加了一些功能分支,但没有出现问题的其他人。



我做了一个 git分支--D develop git checkout -b develop --track origin / develop



当我现在尝试 git pull 我得到一个! [rejected]开发 - > (非快进)



a git远程显示来源显示

 为'git push'配置的本地引用:
开发推动开发(本地过期)

我现在可以做一个 git fetch origin develop git merge FETCH_HEAD 但是我有一些冲突,他想推动很多事情的发展。 (也许旧的分支提交?)并与一个 git reset --hard 我回到了git pull显示被拒绝的消息的地方。

$ b $
$ b

编辑:甚至当我做 git分支时-D开发 / code>我得到 git pull ! [rejected]开发 - >源/开发(非快进) git远程显示源表示一切(最新)



编辑:我一开始没有认出它,因为提交信息是一样的,但是在重置之后,HEAD在远程没有的sha上,所以仍旧在旧分支?

解决方案

我必须删除跟踪分支

  git branch -d -r origin / develop 


Abstract: To reproduce the error

  • create a branch and check it out
  • let someone else delete it and create a new branch with the same name
  • now do git branch -D <branch> and git checkout -b <branch> --track origin/<branch>
  • on a git pull you get ! [rejected] <branch> -> origin/<branch> (non-fast-forward)

to fix it, you have to delete the remote tracking information with git branch -d -r origin/<branch> as well


OLD: Someone deleted the develop branch and created it to remove all feature branches and have the master as base again. Then he added some of the feature branches but not some others that made problems.

I did a git branch -D develop and git checkout -b develop --track origin/develop.

When i now try git pull i get a ! [rejected] develop -> origin/develop (non-fast-forward)

a git remote show origin shows

Local refs configured for 'git push': 
develop       pushes to develop     (local out of date)

i can now do a git fetch origin develop and git merge FETCH_HEAD but then i have some conflicts and he wants to push a lot of things to develop. (maybe the old branch commits?) And with a git reset --hard i'm back where the git pull shows the rejected message ..

How do i checkout the recreated branch best?

EDIT: even when i do git branch -D develop i get with git pull ! [rejected] develop -> origin/develop (non-fast-forward) and git remote show origin said everything (up to date)

EDIT: i didn't recognized it at first, because the commit message was the same, but after a reset the HEAD is on a sha that the remote does not have, so still on the "old" branch ?

解决方案

i had to delete the tracking branch as well

git branch -d -r origin/develop

这篇关于git删除并重新创建分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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