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 ...
随机推荐
- 如何修改MAC自带的PHP的版本?
1. 切换到root目录,新建“.profile”文件 cd ~ vim .profile 2.在.profile文件中添加PATH环境变量 比如这样的路径 export PATH=/Applicat ...
- 数据格式化和ModelAttribute注解的介绍
关于数据传递: 客户端传递数据到服务端: 1.使用普通的形式 A.传递简单的数据 如果是说你传递的数据的名称跟控制层中的形参的名称不一致的情况下需要使用 注解: @RequestParam()如果存在 ...
- DATAX动态参数数据传递
实例:ORACLE到ORACLE的数据传递 编写job.xml文件,添加变量参数 执行datax.py文件时记得带参数 格式:./datax.py –p"-Ddbname=*** -Di ...
- [转载]嵌入式linux下操作GPIO
本文转自:http://blog.csdn.net/mirkerson/article/details/8464231 在嵌入式设备中对GPIO的操作是最基本的操作.一般的做法是写一个单独驱动程序,网 ...
- Python中获得当前目录和上级目录
[转]原文地址:http://blog.csdn.net/liuweiyuxiang/article/details/71154346 获取当前文件的路径: from os import path d ...
- Python使用类
#coding:utf8 from selenium import webdriverfrom time import sleep class urlpage(object): #创建浏览器对象 de ...
- CKEditor 自定义按钮插入服务端图片
CKEditor 富文本编辑器很好用,功能很强大,在加上支持服务端图片上传的CKFinder更是方便, 最近在使用CKFinder的时候发现存在很多问题,比如上传图片的时候,图片不能按时间降序排列,另 ...
- 第三章 Java内存模型(下)
锁的内存语义 中所周知,锁可以让临界区互斥执行.这里将介绍锁的另一个同样重要但常常被忽视的功能:锁的内存语义 锁的释放-获取建立的happens-before关系 锁是Java并发编程中最重要的同步机 ...
- ubuntu系统里vi编辑器时,按方向箭头输入是乱码的ABCD字母?(图文详解)
不多说,直接上干货! 问题详情 ubuntu系统里vi编辑器时,按方向箭头输入是乱码的ABCD字母? 解决办法 是由于预装的vim软件没更新,运行 sudo apt-get install vi ...
- latex bib format
LaTeX 的对参考文献的处理实在是非常的方便,我用过几次,有些体会,写出来供大家参考.当然,自己的功力还不够深,有些地方问题一解决就罢手了,没有细究. LaTeX 对参考文献的处理有这么一些优点: ...