I am making my first commit using GIT in VS Code. I only have one main branch in Github and while I was using git push, I send it as: git push origin/master accidentally.
Error: error: src refspec main does not match any error: failed to push some refs to 'https://github.com/"repoName".git'
I tried git reset origin/main it shows me this message: Unstaged changes after reset: M README.md D a.jpg
And when I tried again with git push origin main, it still throws the same error
I want to push it in my repo in main branch(there is no master branch in mine)
CodePudding user response:
Because on remote server you make changes and this changes should pull first before pushing it
First stash changes that makes in the files:
git stash
Second pull changes from remote branch
git pull origin master
Push again
git push origin master
And push changes in the local repository that you make before pull with stash command
git stash pop
Notice
If you push commits to remote server and edit some commit in the local repository that pushed to remote server, you should rewrite on remote repository and you problem will solve in one command:
git push --force origin master
CodePudding user response:
do a git push
then follow the instructions