1

I was pushing code to master branch and switching to mybranch to fix bugs. Everything worked fine when using $git checkout master and $git checkout mybranch!

The problem is that I once typed git checkout origin instead of git checkout master when I wanted to switch from mybranch into master. Now, every time I want to return to master branch I get this error:

error: pathspec 'master' did not match any file(s) known to git

My question is: how can I get back to master branch using $git checkout master command?

omegap
  • 13
  • 2
  • Run `git branch -a` and cut-and-paste its output into your question, to help others figure out what is going on. – torek Dec 17 '20 at 08:37

1 Answers1

0

Try first to not use git checkout but git switch instead

That switch command won't try to find a file named "master" but will only consider the branch named master.
This assumes Git 2.23+ (August 2019)

VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283