git push origin gives remote part of refspec is not a valid name

前端 未结 7 678
走了就别回头了
走了就别回头了 2020-12-06 05:14

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

相关标签:
7条回答
  • 2020-12-06 05:38

    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.

    0 讨论(0)
  • 2020-12-06 05:38

    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.

    0 讨论(0)
  • 2020-12-06 05:50

    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.

    0 讨论(0)
  • 2020-12-06 05:52

    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.

    0 讨论(0)
  • 2020-12-06 05:53

    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
    
    0 讨论(0)
  • 2020-12-06 05:58

    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:

    • "Why are Github project document page urls case sensitive? What are the negative effects?"
    • "GitHub pushing/pulling error"
    0 讨论(0)
提交回复
热议问题