- Forums
- Scripts
- [FIXED] Error: Pathspec 'master' Did Not Match Any File(s) Known To Git.
this page contains the solution for git error error: pathspec 'master' did not match any file(s) known to git. [8955], Last Updated: Sat May 18, 2024
giter
Wed Dec 09, 2015
0 Comments
1158 Visits
so today i was messing around with my project and i was being funny buy seeing how much project has changed so i thought i go back all the way to the first commit so did the git log command, and got the commit id, then i sent my command:
git checkout 4hf5h4
i was able to see the oldest version of my website.
now that i was happy, i wanted to go back to the latest commit, so the obvious command was
git checkout master
BANG!!!! thats when i got this error message: error: pathspec 'master' did not match any file(s) known to git.
i panic, i didnt know what to do, i searched online and all i found was this command on stackoverflow:
git checkout master
git reset --hard
it didnt work, i thought i has lost all my work. i was so disapointed, but i didnt give up. i kept searching. until finally i found the correct command:
git branch
OUTPUT
gh-pages
master
* new_branch_name
previous_master
when i sent git branch, it displayed all my branches, and while there was a master branch, that was not my project, my project was gh-pages so finally i sent the command:
git checkout gh-pages
it worked!!!
RESOLVED!!