[英]Git deleting a remote branch that's not in remotes/origin
I had a remote branch called new_auth. 我有一个名为new_auth的远程分支。 I wanted a new remote branch to track that remote branch, so I did the following:
我想要一个新的远程分支来跟踪该远程分支,所以我做了以下事情:
git-remote add -t new_auth -m new_auth pivot git@github.com:myco/my_project.git/my_project
Now when I do a git branch -a, I see: 现在,当我做一个git分支-a时,我看到:
* master
new_auth
remotes/origin/HEAD -> origin/master
remotes/origin/new_auth
remotes/pivot/HEAD -> pivot/new_auth
I'd like to delete this remotes/pivot/HEAD -> pivot/new_auth. 我想删除这个遥控器/ pivot / HEAD - > pivot / new_auth。 I've tried:
我试过了:
git push pivot :new_auth
git branch -rd pivot/new_auth
git remote rm pivot
git remote rm pivot/new_auth
No luck. 没运气。 Any ideas?
有任何想法吗?
Your remotes/pivot/HEAD
was created because you gave the -m
option to git remote add
(the command will not automatically create the symref if you leave out -m new_auth
). 您的
remotes/pivot/HEAD
已创建,因为您为git remote add
提供了-m
选项(如果省略-m new_auth
该命令将不会自动创建-m new_auth
)。
A similar symref is created when you clone a repository. 克隆存储库时会创建类似的symref。 If a remote repository has a
HEAD
ref/symref, your clone of it will end up with refs/remotes/origin/HEAD
pointing to one of the remote-tracking branches corresponding to the remote branch pointed to by HEAD
in the remote repository. 如果远程仓库有
HEAD
REF / symref,你对它的克隆将最终refs/remotes/origin/HEAD
指向对应于远程分支指向远程跟踪分支之一HEAD
在远程存储库。
These symrefs let you refer to the “default branch” of a remote by just using the remote's name (eg pivot
“expands” 1 to refs/remotes/pivot/HEAD
, which points to refs/remotes/pivot/new_auth
). 这些symrefs让您只要使用遥控器上的名字指的是远程的“默认分支”(例如
pivot
“展开” 1〜 refs/remotes/pivot/HEAD
,它指向refs/remotes/pivot/new_auth
)。
You can delete the symref with this command: 您可以使用以下命令删除symref:
git remote set-head pivot -d
1 See the <refname>
entry of Specifying Revisions in gitrevisions(7) . 1请参阅gitrevisions中指定修订版的
<refname>
条目(7) 。
Overall, I am not really clear about what you were trying to accomplish with the git remote add
command. 总的来说,我并不清楚你想用
git remote add
命令完成什么。 If pivot
and origin
actually point to the same remote repository (same “Git URL”), then there should be no need for an additional remote. 如果
pivot
和origin
实际指向同一个远程存储库(相同的“Git URL”),那么就不需要额外的远程存储库。 If you just want origin/new_auth
to be the “upstream” branch for your local new_auth
branch, then you can arrange that with 如果您只想将
origin/new_auth
作为本地new_auth
分支的“上游”分支,那么您可以安排
git branch --set-upstream new_auth origin/new_auth
(this can also be done with git push -u
if you already have something ready to push). (如果您已准备好推送,可以使用
git push -u
完成此操作)。 Once the upstream branch has been configured, you can use a bare git pull
to automatically pull from origin/new_auth
when you have new_auth
checked out (you might also want to git config push.default upstream
so that git push
will only push to the upstream branch instead of pushing all branch names that exist in both your local and the remote repositories). 一旦配置了上游分支,你就可以使用一个简单的
git pull
来自你的new_auth
签出时自动从origin/new_auth
提取(你可能还想在git config push.default upstream
以便git push
只会推送到上游分支而不是推送本地和远程存储库中存在的所有分支名称)。
Try this: 尝试这个:
git push remotes/pivot/HEAD :new_auth
or 要么
git push remotes/pivot :new_auth
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.