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

前端 未结 7 677
走了就别回头了
走了就别回头了 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 06:01

    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):

    [+][:]
    

    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 
    

    See Also

    • For a more detailed explanation for refspec syntax, see the official Linux Kernel documentation for git push.
    • For another explanation of refspecs, see Pro Git § 9.5 Git Internals - The Refspec.

提交回复
热议问题