error: pathspec 'test-branch' did not match any file(s) known to git

后端 未结 11 1768
刺人心
刺人心 2020-12-13 17:31

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 c         


        
相关标签:
11条回答
  • 2020-12-13 17:46

    The modern Git should able to detect remote branches and create a local one on checkout.

    However if you did a shallow clone (e.g. with --depth 1), try the following commands to correct it:

    git config remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*'
    git fetch --all
    

    and try to checkout out the branch again.

    Alternatively try to unshallow your clone, e.g. git fetch --unshallow and try again.

    See also: How to fetch all remote branches?

    0 讨论(0)
  • 2020-12-13 17:49

    This error can also appear if your git branch is not correct even though case sensitive wise. In my case I was getting this error as actual branch name was "CORE-something" but I was taking pull like "core-something".

    0 讨论(0)
  • 2020-12-13 17:54

    git fetch && git checkout branch-name

    0 讨论(0)
  • 2020-12-13 17:57

    Solution:

    To fix it you need to fetch first

    $ git fetch origin
    
    $ git rebase origin/master
    

    Current branch master is up to date.

    $ git checkout develop
    

    Branch develop set up to track remote branch develop from origin.

    Switched to a new branch ‘develop’

    0 讨论(0)
  • 2020-12-13 17:59

    Try cloning before doing the checkout.

    do git clone "whee to find it" then after cloning check out the branch

    0 讨论(0)
  • 2020-12-13 18:00

    My friend, you need to create those corresponding branches locally first, in order to check-out to those other two branches, using this line of code

    git branch test-branch  
    

    and

    git branch change-the-title

    then only you will be able to do git checkout to those branches

    Also after creating each branch, take latest changes of those particular branches by using git pull origin branch_name as shown in below code

    git branch test-branch
    git checkout test-branch
    git pull origin test-branch
    

    and for other branch named change-the-title run following code =>

    git branch change-the-title
    git checkout change-the-title
    git pull origin change-the-title
    

    Happy programming :)

    0 讨论(0)
提交回复
热议问题