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

问题描述

我是Git的新用户。我已经创建了一个名为Spoon-Knife的仓库(可用于练习与Git分叉)。然后,我通过运行本地克隆它

$ g $克隆https://github.com/rohinichoudhary/Spoon-Knife.git

该存储库包含三个分支,即


  • master ,

  • test-branch ,

  • 更改标题。



运行 git branch 时,它只显示 * master ,而不是其余的两个分支。当我运行

  git checkout test-branch 

我得到以下错误:

为什么会发生这种情况?如何解决这个问题?

解决方案

git branch 不会列出 test_branch ,因为您的本地回购中不存在这样的本地分支,但是。克隆回购时,不管在远程回购中存在的分支数量是多少,都会在结果克隆中创建并检出一个本地分支( master ,here))你从克隆。在这个阶段, test_branch 只存在于你的仓库中作为,而不是本地分支。

您必须使用Git的旧版本。在更新的版本中(),

只需运行

  git checkout -b test_branch --track origin / test_branch 

代替。或者更新到更新版本的Git。


I am a new user of Git. I have forked a repository called Spoon-Knife (available for practicing forking with Git). Then, I cloned it locally by running

git clone https://github.com/rohinichoudhary/Spoon-Knife.git

This repository contains three branches, i.e.

  • master,
  • test-branch,
  • change-the-title.

When I run git branch, it only shows *master, not the remaining two branches. And when I run

git checkout test-branch

I get the following error:

Why is this happening? How can I solve this problem?

解决方案

git branch doesn't list test_branch, because no such local branch exist in your local repo, yet. When cloning a repo, only one local branch (master, here) is created and checked out in the resulting clone, irrespective of the number of branches that exist in the remote repo that you cloned from. At this stage, test_branch only exist in your repo as a remote-tracking branch, not as a local branch.

You must be using an "old" version of Git. In more recent versions (from v1.7.0-rc0 onwards),

Simply run

git checkout -b test_branch --track origin/test_branch

instead. Or update to a more recent version of Git.

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

08-13 08:25