0

Im trying to push my code from the command line in vs Code but I keep getting this error

fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

anonymous You've successfully authenticated, but GitHub does not provide shell access.

I have already connected my SSH and verified it is working

these are the commands I'm running

PS C:\Users\annon\OneDrive\Documents\GitHub\GraphQLTut> git remote remove origin
error: No such remote: 'origin'
PS C:\Users\anon\OneDrive\Documents\GitHub\GraphQLTut> git remote add origin git@github.com:anon/GraphQLTut.git
PS C:\Users\anon\OneDrive\Documents\GitHub\GraphQLTut> git add .
PS C:\Users\anon\OneDrive\Documents\GitHub\GraphQLTut> git commit -m "init"
On branch main
nothing to commit, working tree clean
PS C:\Users\anon\OneDrive\Documents\GitHub\GraphQLTut> git push
fatal: The current branch main has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin main

PS C:\Users\anon\OneDrive\Documents\GitHub\GraphQLTut>     git push --set-upstream origin main
Enter passphrase for key '/c/Users/anon/.ssh/id_ed25519': 
To github.com:anon/GraphQLTut.git
 ! [rejected]        main -> main (fetch first)
error: failed to push some refs to 'github.com:anon/GraphQLTut.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Ive tried deleting the entire repo and starting over I'm still getting this issue

Currently looking at this discussion Discussion Link

Tried running git pull:

PS C:\Users\tyriq\OneDrive\Documents\GitHub\GraphQLTut> git pull
Enter passphrase for key '/c/Users/tyriq/.ssh/id_ed25519': 
remote: Enumerating objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), 598 bytes | 37.00 KiB/s, done.
From github.com:TyriqueDaniel/GraphQLTut
 * [new branch]      main       -> origin/main
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>
If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> main

PS C:\Users\tyriq\OneDrive\Documents\GitHub\GraphQLTut>     git branch --set-upstream-to=origin/<branch> main
hint: 
hint: If you are planning on basing your work on an upstream
hint: branch that already exists at the remote, you may need to
hint: run "git fetch" to retrieve it.
hint: 
hint: If you are planning to push out a new local branch that
hint: will track its remote counterpart, you may want to use
hint: "git push -u" to set the upstream config as you push.
PS C:\Users\tyriq\OneDrive\Documents\GitHub\GraphQLTut> git push -u
fatal: The current branch main has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin main

PS C:\Users\tyriq\OneDrive\Documents\GitHub\GraphQLTut>     git push --set-upstream origin main
Enter passphrase for key '/c/Users/tyriq/.ssh/id_ed25519': 
To github.com:TyriqueDaniel/GraphQLTut.git
 ! [rejected]        main -> main (non-fast-forward)
error: failed to push some refs to 'github.com:TyriqueDaniel/GraphQLTut.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

1 Answers1

0

This Ended up working for me

It doesn't recognize that you have a master branch, but I found a way to get around it. I found out that there's nothing special about a master branch, you can just create another branch and call it master branch and that's what I did.

To create a master branch:

git checkout -b master And you can work off of that.