简体   繁体   English

Git删除不在遥控器/原点的远程分支

[英]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. 如果pivotorigin实际指向同一个远程存储库(相同的“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.

相关问题 删除远程存储库后清理remotes / origin / master分支 - Clean remotes/origin/master branch after deleting remote repository 将遥控器/来源/分支推送到遥控器 - push remotes/origin/branch to the remote 撤消git branch --track remotes / origin / X - Undo git branch --track remotes/origin/X `git branch -Dr ...`与直接在refs / remotes / origin中删除文件有什么区别吗? - Is there any difference between `git branch -Dr …` vs. deleting the file directly in refs/remotes/origin? 在.git / refs / remotes / origin /下删除已经在远程删除的分支文件是否安全? - Is it safe to delete branch file under .git/refs/remotes/origin/ which is already deleted on remote? 为什么可以在 git checkout -b $local_branch 基于 git checkout remotes/origin/remote_branch 之后看到正确的文件 - why can see right files after git checkout -b $local_branch based on git checkout remotes/origin/remote_branch git branch remotes / origin / foo`是否创建新分支? - Does `git branch remotes/origin/foo` create a new branch? 删除名为 origin/xyz 的本地分支而不删除 Git 中同名 xyz 的远程分支? - Deleting local branch named origin/xyz without deleting remote branch with same name xyz in Git? 修复git分支:refs现在显示refs / remotes / branch和refs / remotes / origin / branch - Repairing git branch: refs now show refs/remotes/branch and refs/remotes/origin/branch 如果有任何提交,是否可以避免`git push`一个分支到 REMOTES - ORIGIN? - Is it possible to avoid to `git push` a branch to REMOTES - ORIGIN if any commits was done?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM