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 ...
随机推荐
- Annotation之四:注解中的-Xlint:unchecked和 -Xlint:deprecation
一.-Xlint:unchecked用法 对如下Test.java编译时 package com.dxz.annotation; import java.util.ArrayList; import ...
- 开发环境无错,部署至测试环境报错“NoSuchMethodError”OR"NoSuchClassError"
背景: 实现一个简单的功能,需要用到jedis的jar包连接Redis.在之前便已经有使用jedis,它的版本比较旧,是2.1的.而新实现的功能,在编码的时候使用的是2.8的.在开发环境完成单元测试后 ...
- 如何删除offline数据文件/表空间上的分区
接上一篇"Oracle 10g RAC全库flashback " http://www.cnblogs.com/cqubityj/p/3265552.html 在打开数据库之前把2 ...
- java连接字符串操作,可用来向sql传值
private static String concat(String tag,String Time) { // TODO Auto-generated method stub // return ...
- 基于C++求两个数的最大公约数最小公倍数
求x,y最大公约数的函数如下: int gys(int x,int y) { int temp; while(x) {temp=x; x=y%x; y=temp;} return y; } x=y的时 ...
- Maven学习笔记2-maven命令
help:active-profiles列出当前构建中活动的Profile(项目的,用户的,全局的). help:effective-pom显示当前构建的实际POM,包含活动的Profile. hel ...
- SpringBoot05 数据操作02 -> JPA接口详解
概览 JpaRepository 继承 PagingAndSortingRepository 继承 CrudRepository 继承 Repository 1 Repository 这是一个空接口, ...
- IFC数据模型在三维引擎中模拟
- Blender 基础 骨架 01
Blender 基础 骨架 01 我使用的Blender版本:Blender V 2.77 前言 本讲介绍: 骨架的基本使用方式. 骨架是角色动画里面最常使用的元素,它可以准确控制一个模型的变形,尤其 ...
- java全栈day06---数组的练习 冒泡排序
水仙花练习功能实现 * A: 水仙花练习功能实现 * a: 题目分析 * 明确什么样的数就是水仙花数.水仙花数是指一个3位数(100-999之间),其每位数字立方之和等于该3位数本身. 如153 = ...