Git:无法签出分支 - 错误:pathspec'...'与git已知的任何文件都不匹配 [英] Git: cannot checkout branch - error: pathspec '...' did not match any file(s) known to git

查看:2073
本文介绍了Git:无法签出分支 - 错误:pathspec'...'与git已知的任何文件都不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不确定为什么我无法结帐以前曾经工作的分支。请参阅下面的命令(注意: co <​​/ code>是 checkout 的别名):

pre $ ra $ @ ramon-desktop:〜/ source / unstilted $ git branch -a
* develop
特性/ datts_right
特性/ user_controlled_menu
feature / user_controlled_site_layouts
master
遥控器/ origin / HEAD - >起源/大师
遥控器/原产地/开发
遥控器/原产地/功能/ datts_right
遥控器/原产地/主控制器
ramon @ ramon-desktop:〜/ source / unstilted $ git co feature / user_controlled_site_layouts
错误:pathspec'feature / user_controlled_site_layouts'与git已知的任何文件都不匹配。

我不确定它是什么意思,而且我似乎也找不到任何我能理解的东西在Google上。



如何结帐该分行,以及我可以做些什么来打破此行为?

UPDATE

我发现这篇文章,并运行 git show-ref 给我:

  97e2cb33914e763ff92bbe38531d3fd02408da46 refs / heads / develop 
c438c439c66da3f2356d2449505c073549b221c1 refs / heads / feature / datts_right
11a90dae8897ceed318700b9af3019f4b4dceb1e refs / heads / feature / user_controlled_menu
c889b37a5ee690986935c9c74b71999e2cf3c6d7裁判/头/主
c889b37a5ee690986935c9c74b71999e2cf3c6d7参/遥控器/产地/ HEAD
e7c17eb40610505eea4e6687e4572191216ad4c6参/遥控器/原产地/开发
c438c439c66da3f2356d2449505c073549b221c1参/遥控器/产地/特征/ datts_right
c889b37a5ee690986935c9c74b71999e2cf3c6d7 refs / remotes / origin / master
23768aa5425cbf29d10ff24274adad42d90d 15cc refs / stash
e572cf91e95da03f04a5e51820f58a7306ce01de refs / tags / menu_shows_published_only
429ebaa895d9d41d835a34da72676caa75902e3d refs / tags / slow_dev



.git 目录
上的更新< user_controlled_site_layouts 位于 refs / heads / feature folder ):

  $ ls .git / refs / heads /功能/ 
datts_right user_controlled_menu user_controlled_site_layouts
$ cat .git / refs / heads / feature / user_controlled_site_layouts
3af84fcf1508c44013844dcd0998a14e61455034

更新于 git show 3af84fcf1508c44013844dcd0998a14e61455034

  $ git show 3af84fcf1508c44013844dcd0998a14e61455034 
commit 3af84fcf1508c44013844dcd0998a14e61455034
作者:Ramon Tayag< xxx@xxxxx.xxx>
日期:星期四5月12日19:00:03 2011 +0800

删除站点布局迁移

diff --git a / db / schema.rb b / db / schema.rb
索引1218fc8..2040b9f 100755
--- a / db / schema.rb
+++ b / db / schema.rb
@@ - 10,7 +10,7 @@

#强烈建议将此文件检入您的版本控制系统。

-ActiveRecord :: Schema.define(:version => 20110511012647)do
+ ActiveRecord :: Schema.define(:version => 20110503040056)do

create_tableattachments,:force => true do | t |
t.stringname
@@ -205,15 +205,6 @@ ActiveRecord :: Schema.define(:version => 20110511012647)do
t.integerold_id
结束

- create_tablesite_layouts,:force => true do | t |
- t.stringname
- t.textdescription
- t.textcontent
- t.integersite_id
- t .datetimecreated_at
- t.datetimeupdated_at
- end
-
create_tablesite_styles,:force => true do | t |
t.textpublished
t.datetimecreated_at


解决方案

我试图检出新分支时遇到了以下错误:


error:pathspec'BRANCH-NAME '与git已知的任何文件都不匹配。


当我尝试 git checkout origin /< ; BRANCH-NAME> 它分离出HEAD



lockquote

b $ b

以下是解决问题的方法吗?

  git remote更新
git fetch
git checkout --track origin /< BRANCH-NAME>


I'm not sure why I'm unable to checkout a branch that I had worked on earlier. See the commands below (note: co is an alias for checkout):

ramon@ramon-desktop:~/source/unstilted$ git branch -a
* develop
  feature/datts_right
  feature/user_controlled_menu
  feature/user_controlled_site_layouts
  master
  remotes/origin/HEAD -> origin/master
  remotes/origin/develop
  remotes/origin/feature/datts_right
  remotes/origin/master
ramon@ramon-desktop:~/source/unstilted$ git co feature/user_controlled_site_layouts 
error: pathspec 'feature/user_controlled_site_layouts' did not match any file(s) known to git.

I'm not sure what it means, and I can't seem to find anything I can understand on Google.

How do I checkout that branch, and what may I have done to break this?

UPDATE:

I found this post, and running git show-ref gives me:

97e2cb33914e763ff92bbe38531d3fd02408da46 refs/heads/develop
c438c439c66da3f2356d2449505c073549b221c1 refs/heads/feature/datts_right
11a90dae8897ceed318700b9af3019f4b4dceb1e refs/heads/feature/user_controlled_menu
c889b37a5ee690986935c9c74b71999e2cf3c6d7 refs/heads/master
c889b37a5ee690986935c9c74b71999e2cf3c6d7 refs/remotes/origin/HEAD
e7c17eb40610505eea4e6687e4572191216ad4c6 refs/remotes/origin/develop
c438c439c66da3f2356d2449505c073549b221c1 refs/remotes/origin/feature/datts_right
c889b37a5ee690986935c9c74b71999e2cf3c6d7 refs/remotes/origin/master
23768aa5425cbf29d10ff24274adad42d90d15cc refs/stash
e572cf91e95da03f04a5e51820f58a7306ce01de refs/tags/menu_shows_published_only
429ebaa895d9d41d835a34da72676caa75902e3d refs/tags/slow_dev

UPDATE on .git directory (user_controlled_site_layouts is in the refs/heads/feature folder):

$ ls .git/refs/heads/feature/
datts_right  user_controlled_menu  user_controlled_site_layouts
$ cat .git/refs/heads/feature/user_controlled_site_layouts
3af84fcf1508c44013844dcd0998a14e61455034

UPDATE on git show 3af84fcf1508c44013844dcd0998a14e61455034

$ git show 3af84fcf1508c44013844dcd0998a14e61455034
commit 3af84fcf1508c44013844dcd0998a14e61455034
Author: Ramon Tayag <xxx@xxxxx.xxx>
Date:   Thu May 12 19:00:03 2011 +0800

    Removed site layouts migration

diff --git a/db/schema.rb b/db/schema.rb
index 1218fc8..2040b9f 100755
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
 #
 # It's strongly recommended to check this file into your version control system.

-ActiveRecord::Schema.define(:version => 20110511012647) do
+ActiveRecord::Schema.define(:version => 20110503040056) do

   create_table "attachments", :force => true do |t|
     t.string   "name"
@@ -205,15 +205,6 @@ ActiveRecord::Schema.define(:version => 20110511012647) do
     t.integer  "old_id"
   end

-  create_table "site_layouts", :force => true do |t|
-    t.string   "name"
-    t.text     "description"
-    t.text     "content"
-    t.integer  "site_id"
-    t.datetime "created_at"
-    t.datetime "updated_at"
-  end
-
   create_table "site_styles", :force => true do |t|
     t.text     "published"
     t.datetime "created_at"

解决方案

I was getting following error when I tried to checkout new branch

error: pathspec 'BRANCH-NAME' did not match any file(s) known to git.

When I tried git checkout origin/<BRANCH-NAME> it went to detached HEAD

(detached from origin/)

Did following to resolve the issue

git remote update
git fetch 
git checkout --track origin/<BRANCH-NAME>

这篇关于Git:无法签出分支 - 错误:pathspec'...'与git已知的任何文件都不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆