简体   繁体   English

为什么我没有收到错误“致命:当前分支 A 没有上游分支”。

[英]Why I don't get the error “fatal: The current branch A has no upstream branch.”

It's about why I do not get the error "fatal: The current branch A has no upstream branch."这就是为什么我没有收到错误“致命:当前分支 A 没有上游分支”的原因。

I deleted the REMOTE branch A with the command git push origin :A .我删除了远程分支A执行命令git push origin :A Then I switched to LOCAL branch A with the command git checkout A .然后我使用命令git checkout A切换到LOCAL分支git checkout A After adding, commiting and pushing, I don't get the error "fatal: The current branch A has no upstream branch."添加、提交和推送后,我没有收到错误“致命:当前分支 A 没有上游分支”。

Why does this error not appear even though the remote branch A does not exist because I deleted it before?为什么即使远程分支A不存在也不会出现此错误,因为我之前删除了它?

Because the error you expect to have is not related to the existence or not of the branch in the remote.因为您期望的错误与远程分支的存在与否无关。 It is related to the fact that your local branch has a "destination" defined ("upstream branch").这与您的本地分支定义了“目的地”(“上游分支”)这一事实有关。

When you delete the remote branch, you don't unset the upstream branch from your local branch.删除远程分支时,不会从本地分支取消上游分支的设置。

Your local branch can have a upstream branch defined that doesn't exist yet/anymore.您的本地分支可以定义一个尚不存在/不再存在的上游分支。

Even when you deleted the remote branch, your local repository still has the configuration for your local branch to point to a specific remote branch.即使您删除了远程分支,您的本地存储库仍然具有本地分支的配置以指向特定的远程分支。 You can check this configuration by looking in the file .git/config .您可以通过查看文件.git/config来检查此配置。 You should see an entry like the following, just with your branch name:您应该会看到如下所示的条目,仅包含您的分支名称:

[branch "master"]
    remote = origin
    merge = refs/heads/master

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 致命:当前分支master没有上游分支 - fatal: The current branch master has no upstream branch Git: fatal: 当前分支 XXX 没有上游分支(但它有上游分支) - Git: fatal:The current branch XXX has no upstream branch (but it HAS the upstream branch) 如何压制“致命:您当前分支的上游分支与您当前分支的名称不匹配”? - How do I squelch "fatal: The upstream branch of your current branch does not match the name of your current branch"? 当我运行“git push”时,我得到“您当前分支的提示在其远程后面”但当前分支没有上游跟踪分支 - When I run "git push" I get "tip of your current branch is behind its remote" but the current branche has no upstream tracking branch 我尝试拉一个远程分支。 错误:致命:无法锁定参考 - I try pull a remote branch. Error: fatal: cannot lock ref 为什么我收到那个错误? 致命:在上游源中找不到远程分支 redux-basics - why i am getting that error ? fatal: Remote branch redux-basics not found in upstream origin git push已合并另一个分支的代码。 为什么? - git push has merged code from another branch. why? 主题分支中的`git rebase upstream-branch`发生致命错误 - Fatal error with `git rebase upstream-branch` in topic branch 致命:您当前分支的上游分支与您当前分支的名称不匹配 - fatal: The upstream branch of your current branch does not match the name of your current branch Git:致命:当前的分支主机有多个上游分支,拒绝推送 - Git: fatal: The current branch master has multiple upstream branches, refusing to push
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM