Git使用之(pathspec master did not match any file(s) known to git)
一 问题概述
今天在工作中遇到一个问题,使用很久的一个local git repository,里面只有develop分支,那么现在想将分支切换到master分支,问题来了,在切换到master分支时:
- git checkout master
提示如下错误:
- error: pathspec 'master' did not match any file(s) known to git
二 问题解决
1.首先我们看一下分支情况:
- git branch -a
- * develop
- remotes/composer/develop
- remotes/composer/feature/194
- remotes/composer/feature/198
- remotes/composer/feature/199
- remotes/composer/feature/200
- remotes/composer/master
- remotes/origin/HEAD -> origin/develop
- remotes/origin/develop
- remotes/origin/feature/194
- remotes/origin/feature/198
- remotes/origin/feature/199
- remotes/origin/feature/200
- remotes/origin/master
2.如果没有看到你想要的分支,先获取所有分支:
- git fetch
3.切换到远程master分支:
- git checkout origin/master
提示如下:
- Note: checking out 'origin/master'.
- You are in 'detached HEAD' state. You can look around, make experimental
- changes and commit them, and you can discard any commits you make in this
- state without impacting any branches by performing another checkout.
- If you want to create a new branch to retain commits you create, you may
- do so (now or later) by using -b with the checkout command again. Example:
- git checkout -b new_branch_name
- HEAD is now at 4beea49... Merge branch 'develop' into 'master'
执行git branch,效果如下:
- * (detached from origin/master)
- develop
5.现在我们可以从当前的detached分支切换并新建分支,可以理解为即将新创建的分支是由当前detached 分支出来的(为了为后续做准备,此处新分支就叫做master):
- git checkout -b master
5.这时我们使用git pull会提示如下错误:
- There is no tracking information for the current branch.
- Please specify which branch you want to merge with.
- See git-pull(1) for details
- git pull <remote> <branch>
- If you wish to set tracking information for this branch you can do so with:
- git branch --set-upstream-to=<remote>/<branch> master
说明我们新建立的master分支还不能和远程的master分支建立追踪关系(虽然表面我们看似已经建立了master分支,但git不认为它和远程的master有任何关系),当然,您可以按照上面提示那样,通过git pull指定远程的分支和本地的分支来进行更新,但此处我们使用提示中的第二种方式,建立本地分支和远程分支的追踪关系:
- git branch -u origin/master master
6.这时我们执行git pull来看看什么反馈:
- Already up-to-date.
总结:其实git的人性化做的非常的完备,有时我们不要惧怕提示,而要从中找到问题的解决方法,并时常利用好:
- man git
- man git branch
- and so forth!
Bye!
Git使用之(pathspec master did not match any file(s) known to git)的更多相关文章
- error: pathspec 'master' did not match any file(s) known to git.
问题描述: 在远程服务器上新建裸仓库git --bare init : git clone裸仓库到本地: 本地新建并切换分支xccdev,git checkout -b xccdev: 从xccde ...
- git——创建分支后,切换分支报错(error: pathspec 'master' did not match any file(s) known to git)
error: pathspec 'master' did not match any file(s) known to git 解决办法: 1.查看分支 git branch -a 2.获取所有分支 ...
- git commit 提交不了 error: pathspec 'project'' did not match any file(s) known to git.
1. 问题--使用git将代码提交到码云,使用到以下命令时: git commit -m 'init project' # 报错 error: pathspec 'project'' did not ...
- Error: pathspec '*' did not match any file(s) known to git.
git切换分支报错 error: pathspec 'develop' did not match any file(s) known to git. 解决办法如下: plumm@MACY-PC MI ...
- xxx did not match any file(s) known to git
切换分支的时候,报了标题这么个错误,error: pathspec ''xxx did not match any file(s) known to git. 看见不能切换分支,我首先 git sta ...
- git切换分支报错:error: pathspec 'origin/XXX' did not match any file(s) known to git
项目上有一个分支test,使用git branch -a看不到该远程分支,直接使用命令git checkout test报错如下: error: pathspec 'origin/test' did ...
- git 提交 src refspec master does not match any
git init 产生的目录解释 error: src refspec master does not match any. 引起该错误的原因是,目录中没有文件,空目录是不能提交上去的 error ...
- Git:错误:error:src refspec master does not match any
新建立了一个远程仓库,想着把项目放上去.于是在项目目录上: git init 然后就添加远程库 git remote add origin xxxx.git 然后就想push: git push -u ...
- GIT问题,error:src refspec master does not match any
将本地GIT版本库PUSH到一个GITHUB上一个空的版本库时可能会出现如下错误error:src refspec master does not match any原因: 本地版本库为空, 空目录不 ...
随机推荐
- springboot 之 连接数据库
在连接数据库的时候,配置文件是这样写的,但是却一直报 java.sql.SQLException: Access denied for user 'root'@'localhost' (using p ...
- Tomcat配置及不依赖IDEA部署web应用
http:tomcat.apache.org 下载tomcat文件包 我使用的tomcat9的版本 Tomcat9014使用的是Servlet4.0 解压即可,目录如下 bin :启动和关闭tomca ...
- php优秀框架codeigniter学习系列——CI_Controller分析
该类是一个超级大的父类,它将在 CodeIgniter.php 中实例化化过的类,通通加载成它的类成员变量,所以可以方便的进行各种操作.各种应用控制器类,都会继承 CI_Controller 类. _ ...
- Map、Set、List区别
转:https://www.cnblogs.com/jing99/p/6947549.html 提到集合之前,先说说数组Array和集合的区别: (1)数组是大小固定的,并且同一个数组只能存放类型 ...
- PostMan Test 的脚本scripts编写方法
设置环境变量 pm.environment.set("variable_key", "variable_value"); 将一个嵌套的对象设置为一个环境变量 v ...
- JdbcTemplate 配置多数据源(完全照抄,完整)
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://mave ...
- Js/Session和Cookies的区别
1.cookies数据存放在客户的浏览器上面,session放在服务器上面.2.cookies不安全,别人可以分析浏览器的数据进行cookies的欺骗,考虑到安全性,应该使用cookie3.sessi ...
- JavaSE-类
一.基础概念:计算机语言的发展是接近人的思维方式演变:汇编语言(面向机器).C语言(面向过程).java(面向对象) 二.成员变量和局部变量: 1.全名定义一个类: Package 包名: Class ...
- Spring-AOP 基于注解的实现
一.AOP: 是对OOP编程方式的一种补充.翻译过来为“面向切面编程”. 可以理解为一个拦截器框架,但是这个拦截器会非常武断,如果它拦截一个类,那么它就会拦截这个类中的所有方法.如对一个目标列的代理, ...
- window10单机安装storm集群
适合范围:storm自由开源的分布式实时计算系统,擅长处理海量数据.适合处理实时数据而不是批处理. 安装前的准备 1.安装zookeeper ①下载zookeeperhttps://zookeeper ...