[git] error: src refspec master does not match any

FWIW, ran into same error, but believe it came about due to the following sequence of events:

  • Remote Git repo was created with master branch.
  • Local clone was then created.
  • Remote Git repo was then modified to include a dev branch, which was defined as the default branch, in conjunction with permissions added to the master branch preventing changes without a pull request.
  • Code updates occurred in the local clone, ready to be pushed to the remote repo.

Then, when attempting to push changes from the local to the remote, received error "src refspec master does not match any", or when attempting to push to dev, "src refspec dev does not match any".

Because changes were pending in the local clone, I did not want to blast it and refresh. So, fixed the issue by renaming the local branch to dev...

$ git branch -m dev

...followed by the normal push of git push origin dev, which worked this time without throwing the aforementioned error.

Examples related to git

Does the target directory for a git clone have to match the repo name? Git fatal: protocol 'https' is not supported Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) git clone: Authentication failed for <URL> destination path already exists and is not an empty directory SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443 GitLab remote: HTTP Basic: Access denied and fatal Authentication How can I switch to another branch in git? VS 2017 Git Local Commit DB.lock error on every commit How to remove an unpushed outgoing commit in Visual Studio?

Examples related to git-push

Fix GitLab error: "you are not allowed to push code to protected branches on this project"? ! [rejected] master -> master (fetch first) Git - What is the difference between push.default "matching" and "simple" error: src refspec master does not match any Issue pushing new code in Github Can't push to GitHub because of large file which I already deleted Changing the Git remote 'push to' default What does '--set-upstream' do? Git push hangs when pushing to Github? fatal: 'origin' does not appear to be a git repository

Examples related to git-remote

Why does Git tell me "No such remote 'origin'" when I try to push to origin? Git - What is the difference between push.default "matching" and "simple" error: src refspec master does not match any How to connect to a remote Git repository? Changing the Git remote 'push to' default What does '--set-upstream' do? Git: How to remove remote origin from Git repo Git push error: "origin does not appear to be a git repository" How to add a local repo and treat it as a remote repo Git branching: master vs. origin/master vs. remotes/origin/master