Git: cannot checkout branch - error: pathspec '…' did not match any file(s) known to git

后端 未结 30 3278
太阳男子
太阳男子 2020-11-27 23:54

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 checkou

30条回答
  •  自闭症患者
    2020-11-28 00:35

    I got this error when trying to checkout a branch via:

    git checkout branchX
    

    which I had not checked out before. It only worked when explicitly stating the remote:

    git checkout --track origin/branchX
    

    The reason for this was, that I had 2 different remotes (origin + sth. else) configured in git config. As I didn't need the second remote, I removed it and voilá, it worked. The alternative to set the default remote via:

    checkout.defaultRemote=origin
    

    did not work for me

提交回复
热议问题