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原因: 本地版本库为空, 空目录不 ...
随机推荐
- 转载:入门Webpack,看这篇就够了
写在前面的话 阅读本文之前,先看下面这个webpack的配置文件,如果每一项你都懂,那本文能带给你的收获也许就比较有限,你可以快速浏览或直接跳过:如果你和十天前的我一样,对很多选项存在着疑惑,那花一段 ...
- SQL Server-常用分页语句
--SQL Server 2012及以上版本 , select field1, field2 from table1where 1=1 order by field1 offset @pageInde ...
- 微信浏览器软键盘弹出与页面resize的问题
使用微信打开网页,弹出软键盘时遇到的兼容问题 过去开发中遇到过很多这种情况,页面底部需要固定定位一个按钮,广告栏或者菜单栏,页面中有表单项需要填写,在打开手机虚拟键盘的时候,底部固定定位的元素会处在软 ...
- ajax请求,函数外无法获取请求的数据问题解决
一.开发中遇到需要通过ajax请求获取其他函数能否执行的状态,但是当赋值给statusFlag时发现无法赋值:ajax请求默认为异步的方式,该请求的操作被放置在任务队列中,并不会按顺序执行,所以被赋值 ...
- CSS常用属性-xy
一.文本Text CSS text-align 属性 文本对齐方式 CSS text-decoration 属性 text-decoration 属性规定添加到文本的修饰 CSS line-heigh ...
- iOS开发,改变系统铃声音量和静音,并非媒体播放音量
使用AVSystemController可以改变系统声音,而且是铃声,并非媒体播放的声音. 它可以让iPhone手机静音.但是,AVSystemController存在于私有Celestial框架中. ...
- React native 中 SectionList用法
一.代码 import React, { Component } from 'react'; import { AppRegistry, View, Text, SectionList, } from ...
- 【sem竞价】点击量较多、咨询少怎么解决?
点击量较多咨询少可能这种情况对于竞价技术专员来说比较常见的现象之一,在搜客大伟看来主要取决于两方面因素:一方面是外界环境因素影响:另一方面也就是我们下面主要介绍的sem竞价推广账户内部因素. 如下图, ...
- wxPython制作跑monkey工具(python3)
一. wxPython制作跑monkey工具python文件源代码内容Run Monkey.py如下: #!/usr/bin/env python import wx import os import ...
- s21day14 python笔记
s21day14 python笔记 一.内容回顾及补充 参数补充 对于函数的默认值是可变类型 # 如果要想给value设置默认是空列表 # 不推荐(坑) def func(data,value=[]) ...