0

I have installed the git ,created repository , then I have tried to push from vs code to github repository with cmd

git push -u origin main

Git say error: failed to push some refs to 'github.com:loobj126/boredape-dapp-bj.git''

What's the problem?

https://github.com/loobj126/boredape-dapp-bj

enter image description here

i ve few approach yet still not resolve

https://komodor.com/learn/how-to-fix-failed-to-push-some-refs-to-git-errors/

enter image description here

Latest input :

after initialize

[2022-04-20T08:44:06.669Z] Validating found git in: C:\Program Files\Git\cmd\git.exe
[2022-04-20T08:44:06.796Z] Using git 2.35.3.windows.1 from C:\Program Files\Git\cmd\git.exe
[2022-04-20T10:45:43.723Z] > git init [128ms]
[2022-04-20T10:45:44.399Z] > git rev-parse --git-dir [72ms]
[2022-04-20T10:45:44.403Z] Open repository: c:\Users\loobj\boredape-dapp-bj
[2022-04-20T10:45:44.606Z] > git fetch [197ms]
[2022-04-20T10:45:44.676Z] > git symbolic-ref --short HEAD [119ms]
[2022-04-20T10:45:44.765Z] > git for-each-ref --format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track) refs/heads/master refs/remotes/master [85ms]
[2022-04-20T10:45:44.872Z] > git remote --verbose [99ms]
[2022-04-20T10:45:44.888Z] > git for-each-ref --sort -committerdate --format %(refname) %(objectname) %(*objectname) [119ms]
[2022-04-20T10:45:45.019Z] > git config --get commit.template [122ms]
[2022-04-20T10:45:45.040Z] > git config --local branch.master.github-pr-owner-number [121ms]
[2022-04-20T10:45:45.300Z] > git symbolic-ref --short HEAD [101ms]
[2022-04-20T10:45:45.385Z] > git for-each-ref --format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track) refs/heads/master refs/remotes/master [80ms]
[2022-04-20T10:45:45.490Z] > git for-each-ref --sort -committerdate --format %(refname) %(objectname) %(*objectname) [101ms]
[2022-04-20T10:45:45.507Z] > git remote --verbose [115ms]
[2022-04-20T10:45:45.589Z] > git config --get commit.template [76ms]

Click push

enter image description here enter image description here

[2022-04-20T10:59:18.763Z] > git push boredape-dapp-bj master [153ms] [2022-04-20T10:59:18.763Z] error: src refspec master does not match any error: failed to push some refs to 'https://github.com/loobj126/boredape-dapp-bj.git' [2022-04-20T11:00:41.028Z] > git fetch [141ms] [2022-04-20T11:00:41.220Z] > git symbolic-ref --short HEAD [68ms] [2022-04-20T11:00:41.286Z] > git for-each-ref --format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track) refs/heads/master refs/remotes/master [63ms] [2022-04-20T11:00:41.380Z] > git for-each-ref --sort -committerdate --format %(refname) %(objectname) %(*objectname) [91ms] [2022-04-20T11:00:41.394Z] > git remote --verbose [102ms] [2022-04-20T11:00:41.485Z] > git config --get commit.template [84ms]

2
  • can you paste full error message(not in image format)? Commented Apr 20, 2022 at 8:35
  • added latest input how does it happen Commented Apr 20, 2022 at 11:05

4 Answers 4

7

Solution 1: for error: src refspec master does not match any. All you need to perform is git commit with a proper message and then do git push to the remote origin to avoid any errors.

mkdir repo && cd repo
git remote add origin /path/to/origin.git
git add .

git commit -m "initial commit"
git push origin master

Solution 2 – First, check what refs you have, and once you find that, make a git push to the specific remote branch.

# To get all the ref 
git show-ref

# replace with your branch name according to ref 
git push origin HEAD:<branch>

this worked for me.

Sign up to request clarification or add additional context in comments.

2 Comments

i try run 'git show-ref' but no result. loobj@LAPTOP-SACR77J5 MINGW64 ~/boredape-dapp-bj (master) $ git show-ref loobj@LAPTOP-SACR77J5 MINGW64 ~/boredape-dapp-bj (master) $
for solution (1) , it hits below error loobj@LAPTOP-SACR77J5 MINGW64 ~/boredape-dapp-bj (master) $ git push origin master [email protected]: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
1

I had the same problem, mine was related to having a tag and a branch with the same name:

e.g.

tag\release_3_0_3
branch\release_3_0_3

To solve, I created a new tag:

tag\tag_release_3_0_3

And deleted

 tag\release_3_0_3

Then was able to push without any errors.

Comments

0

To fix the error, go on and run following commands:

git pull --rebase origin main

git push -u origin main

If the first command above runs successfully, you should get a response that says: Successfully rebased and updated refs/heads/main.

The second command pushes your local repo's current state to the remote branch.

ref: https://www.freecodecamp.org/news/error-failed-to-push-some-refs-to-how-to-fix-in-git/

Comments

0

It might also be problem of branching, you're in different branch master whereas the remote branch is main:

  • List all branches:
$ git branch
* master
  • Create and switch to the same branch of remote repo:
$ git checkout -b main
Switched to a new branch 'main'
  • Push to the remote branch:
$ git push origin main

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.