当 "username/feature-name" 分支存在于原点但现在已删除时尝试创建 "username" 分支时出错
Get error when try to create "username" branch when "username/feature-name" branch existed on origin but now deleted
我之前创建的分支如下:
git branch "username/feature-name"
现在分支被合并到开发中,我不再需要那个分支了,我需要分支:"username"
但是当我运行:
git branch "username"
我收到以下错误消息:
cannot lock ref 'refs/heads/username':
'refs/heads/username/feature-name' exists; cannot create
'refs/heads/username'
我该如何解决这个问题?
我运行
git fetch origin develop
但这并没有解决问题。
如果我这样做:
git branch -a
我和其他人一起进入分支以下:
...
"username/feature-name"
"remote/origin/username/feature-name"
...
...
如果我运行:
git remote show origin
我得到:
远程分支下:
Remote branches:
refs/remotes/origin/username/feature-name stale (use 'git remote prune' to
remove)
这不会出现在本地分支下。
我不确定 git 远程 p运行e 会做什么,请需要指导。
如果问题不清楚,请告诉我。
运行:
git remote prune origin // To remove stale branch from remote
运行:
git branch -d username/feature-name // to remove branch from local
这个问题已解决。
参考:Git prune
我之前创建的分支如下:
git branch "username/feature-name"
现在分支被合并到开发中,我不再需要那个分支了,我需要分支:"username"
但是当我运行:
git branch "username"
我收到以下错误消息:
cannot lock ref 'refs/heads/username': 'refs/heads/username/feature-name' exists; cannot create 'refs/heads/username'
我该如何解决这个问题?
我运行
git fetch origin develop
但这并没有解决问题。
如果我这样做:
git branch -a
我和其他人一起进入分支以下:
...
"username/feature-name"
"remote/origin/username/feature-name"
...
...
如果我运行:
git remote show origin
我得到:
远程分支下:
Remote branches:
refs/remotes/origin/username/feature-name stale (use 'git remote prune' to
remove)
这不会出现在本地分支下。
我不确定 git 远程 p运行e 会做什么,请需要指导。
如果问题不清楚,请告诉我。
运行:
git remote prune origin // To remove stale branch from remote
运行:
git branch -d username/feature-name // to remove branch from local
这个问题已解决。
参考:Git prune