17

I have created a remote repo using my GitHub account at https://github.com/darKoram/sphero_tracker.git. So far it just contains some wiki pages, but I'm ready to upload my code.

I use

git push origin git@github.com:/darkoram/shpero_tracker.git

I also tried

git push origin https://github.com/darKoram/sphero_tracker.git

both times I get

remote part of refspec is not a valid name in https://github.com/darKoram/sphero_tracker.git

I've pushed before without problems. Just don't know what I'm doing wrong here.


I got a little further. Followed the instructions by marshall and the generating-ssh-keys link below, but still get

git push -u origin master ERROR: Repository not found. fatal: The remote end hung up unexpectedly

I've established that my ssh keys are good and verified that they exist on github by tring to add what's in my id_rsa.pub to my github (it said the key already existed).

$ ssh -T git@github.com Hi darKoram! You've successfully authenticated, but GitHub does not provide shell access.

https://help.github.com/articles/generating-ssh-keys

ssh -T -p 443 git@ssh.github.com The authenticity of host '[ssh.github.com]:443 ([207.97.227.248]:443)' can't be established. RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '[ssh.github.com]:443,[207.97.227.248]:443' (RSA) to the list of known hosts. Hi darKoram! You've successfully authenticated, but GitHub does not provide shell access

git remote -v origin git@github.com:darKoram/shpero_tracker.git (fetch) origin git@github.com:darKoram/shpero_tracker.git (push)

but the repo certainly seems to exist http://www.pasteall.org/pic/show.php?id=36560

Kev
  • 118,037
  • 53
  • 300
  • 385
darKoram
  • 1,113
  • 1
  • 14
  • 25

7 Answers7

14

Why not follow the instructions GitHub gives you?

git remote add origin git@github.com:darkoram/shpero_tracker.git
git push -u origin master

The commands you're issuing are saying "push to the remote repo named origin the branch named git@github.com:/darkoram/shpero_tracker.git", which is obviously not correct.

Andrew Marshall
  • 95,083
  • 20
  • 220
  • 214
9

The original poster's original question says:

I use

git push origin git@github.com:/darkoram/shpero_tracker.git

I also tried

git push origin https://github.com/darKoram/sphero_tracker.git

both times I get

remote part of refspec is not a valid name in https://github.com/darKoram/sphero_tracker.git

The error refers to the fact that you're not using a valid refspec. A refspec takes the following form (items in [] are optional, and items in <> are parameters):

[+]<source>[:<destination>]

In the format above, both the source and the destination are references, and branches in Git are references, so you can use branches as refspecs. For example, the following are both valid and equivalent refspecs:

master
master:master

Using the two refspecs with git push:

git push origin master
git push origin master:master

will both push the local branch master to the branch named master on the remote origin.

Your Problem

You used:

git push origin git@github.com:/darkoram/shpero_tracker.git

git@github.com:/darkoram/shpero_tracker.git is not a vaid reference/branch; it's the URL for your remote repo. That's probably why Git is complaining that the refspec is not valid.

The correct way to push a branch would be:

git push origin <branch>

See Also

Guildenstern
  • 2,179
  • 1
  • 17
  • 39
4

I use

git push origin git@github.com:/darkoram/shpero_tracker.git

I also tried

git push origin https://github.com/darKoram/sphero_tracker.git

both times I get

remote part of refspec is not a valid name in >https://github.com/darKoram/sphero_tracker.git

The solution is to put the branch name at the end of the git command:

git push https://github.com/darKoram/sphero_tracker.git master
ARK
  • 41
  • 5
2

Please consider the case (uppercase, lowercase) you are using for those remote addresses:

git remote add origin git@github.com:darKoram/shpero_tracker.git
# NOT:
git remote add origin git@github.com:darkoram/shpero_tracker.git # won't work
#                                      ^^^
#                                       |

See:

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
2

In the end, i was able to connect, but when trying git push origin master i was getting "fast forward" errors despite the fact that my repo was created with only the default Readme.md. I tried the suggestions in the man pages, but in the end, when my dev folders were pushed to github the folder showed up as green and could not be opened. The git pull --rebase I did also somehow excluded my dev files from my local git repo and i've found no way to add them back.

In the end, i had to create a new github repo and a new local repo. The key in the process is step 3 which pulls the nearly empty (except for Readme.md) repo before attempting to push to it.

  1. create github repo
  2. git add remote origin (https://... the url in the window on github page)
  3. git clone origin master
  4. create local repo; add; commit;
  5. git push origin

I suppose if i didn't accept the dialog box offer to create Readme for repo that 3 would be un-necessary, but it's strange to me that this default option derails the simple repo creation process as elaborated in so many tutorials on the subject.

darKoram
  • 1,113
  • 1
  • 14
  • 25
1

In my case I am also getting the same error.

fatal: remote part of refspec is not a valid name in https://github.com/username/repo.git

Firstly I thought it is due to changing the username( as I recently change my username on github) but that's not a problem.

When I tried git fetch and then git pull but getting the same error.

At Last this is just solved by

git push origin master 

No Idea but this worked.

Sajjan Kumar
  • 353
  • 1
  • 3
  • 16
0

I had a similar problem today. FWIW, this fixed it:

git fetch followed by git pull origin mybranch (response: "Already up-to-date")

then git push origin mybranch.

I suspect maybe something related to the upstream parent branch needed to be fetched (?). If someone else can explain why this fixed it, I'm all ears.

szeitlin
  • 3,197
  • 2
  • 23
  • 19