Git master branch has no upstream branch的解决
Git master branch has no upstream branch的解决
在push代码时,出现“git master branch has no upstream branch”问题的原因是没有将本地的分支与远程仓库的分支进行关联。如下图所示:
具体原因: 出现这种情况主要是由于远程仓库太多,且分支较多。在默认情况下,git push时一般会上传到origin下的master分支上,然而当repository和branch过多,而又没有设置关联时,git就会产生疑问,因为它无法判断你的push目标。
Git 的 “master” 分支并不是一个特殊分支。 它就跟其它分支完全没有区别。 之所以几乎每一个仓库都有 master 分支,是因为
git init命令默认创建它,并且大多数人都懒得去改动它
远程仓库名字 “origin” 与分支名字 “master” 一样,在 Git 中并没有任何特别的含义一样。origin” 是当你运行
git clone时默认的远程仓库名字。 如果你运行 git clone -o booyah,那么你默认的远程分支名字将会是 booyah/master。
解决办法其实就是确定这两个值,方法有两种:
- 第一种如上图中的提示:
git push --set-upstream origin master。其中的origin是你在clone远程代码时,git为你创建的指向这个远程代码库的标签,它指向repository。为了能清楚了解你要指向的repository,可以用命令git remote -v进行查看。master是你远程的branch,可以用git branch -a查看所有分支,远程分支是红色的部分。然后确定好这两个值后,将值换掉即可。 - 另一种方法是:
git push -u origin master。同样根据自己的需要,替换origin和master。
两个命令的区别是第一条命令是要保证你的远程分支存在,如果不存在,也就无法进行关联。而第二条指令即使远程没有你要关联的分支,它也会自动创建一个出来,以实现关联。
---------------------
本文来自 benben_2015 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/benben_2015/article/details/78803753?utm_source=copy
Git master branch has no upstream branch的解决的更多相关文章
- git推送代码报错:fatal: The current branch master has no upstream branch. To push the current branch and set the remote as upstream
情景再现 远程新建仓库,然后本地 git bash执行以下代码 git init git add . git commit -m 'xxx' git remote add origin https:/ ...
- 【IDEA】 Can't Update No tracked branch configured for branch master or the branch doesn't exist. To make your branch track a remote branch call, for example, git branch --set-upstream-to origin/master
IDEA点击GIT更新按钮时,报错如下: Can't UpdateNo tracked branch configured for branch master or the branch doesn' ...
- [Practical Git] Switching between current branch and last checkout branch
When working on a project, it is much easier to work on features and bugs in isolation of the rest o ...
- git merge,rebase和*(no branch)
上一篇:http://blog.csdn.net/xiaoputao0903/article/details/23933589,说了git的分支,相关的使用方法没说到可是仅仅要google就能搜出一大 ...
- git常见问题之git pull时Please specify which branch you want to merge with.
$ git pull时遇到如下提示 $ git pull warning: no common commits remote: Counting objects: 5, done. remote: C ...
- Git 协作:Fetch Pull Push Branch Remote Rebase Cherry-pick相关
前言 学习git的时候,我们首先学习的是最常用的,自己独立开发Software时用的命令: git init //初始化git仓库 git add <file_name> //将文件添加到 ...
- eclipse git 一个错误:the current branch is not configured for pull No value for key branch.xxx.merge found
eclipse git 一个错误:the current branch is not configured for pull No value for key branch.xxx.merge fou ...
- git 报错 gitThere is no tracking information for the current branch. Please specify which branch you w
新建本地分支后将本地分支推送到远程库, 使用git pull 或者 git push 的时候报错gitThere is no tracking information for the current ...
- Git master合并分支时提示“Already up-to-date”
Git master合并分支时提示"Already up-to-date" 在使用Git把当前分支合并到master提示"Already up-to-date&quo ...
随机推荐
- HTTP-Runoob:教程
ylbtech-HTTP-Runoob:教程 1.返回顶部 1. HTTP 教程 HTTP协议(HyperText Transfer Protocol,超文本传输协议)是因特网上应用最为广泛的一种网络 ...
- Oracle user,role,profile常规操作--用户,权限,角色,配置文件
Oracle user,role,profile常规操作--用户,权限,角色,配置文件 1 权限查询 1查看所有用户 SQL> select username,account_status,lo ...
- 基于mjpg-streamer网络视频服务器移植
MJPG简介: MJPG是MJPEG的缩写,但是MJPEG还可以表示文件格式扩展名. MJPEG 全名为 "Motion Joint Photographic Experts Group&q ...
- Python类(八)-类的起源
首先用type()看一下类和实例化对象的类型 # -*- coding:utf-8 -*- __author__ = "MuT6 Sch01aR" class Person(obj ...
- 【263】Linux 添加环境变量 & 全局 shell 脚本
Linux电脑添加环境变量 方法一:通过修改 profile 文件添加环境变量 1. 打开终端,输入[vi /etc/profile],如下所示,点击回车 [ocean@ygs-jhyang-w1 L ...
- sed对指定行添加或删除注释
如下文本 zimu.txt aaaaa #bbbbbb cccccc dddddd 以下命令如果需要在文本中更改 需要加 -i 或者 -ri参数 用sed在aaa前加#注释 sed 's/^ ...
- VS2010 rdlc报表无法显示“数据源”选项
- MMSeg中文分词算法
Java中有一些开源的分词项目,比如:IK.Paoding.MMSEG4J等等.这里主要说的是MMSEG4J中使用的MMSeg算法.它的原文介绍在:http://technology.chtsai.o ...
- spring----AOP注解以及spring的JDBC和事务
技术分析之:Spring框架的AOP技术(注解方式) 1. 步骤一:创建JavaWEB项目,引入具体的开发的jar包 * 先引入Spring框架开发的基本开发包 * 再引入Spring框架的AOP的开 ...
- 批处理基本知识以及进阶 V2.0
批处理基本知识以及进阶 将以要执行的程序指令 , 像在 dos 模式下一下写入记事本 , 保存成 bat 文件 , 就可以执行了 一 . 简单批处理内部命令简介 1.Echo 命令 打开回显或关闭请求 ...