Error when “git push” to github

I have a public repository at github.com with 2 branches : master and test.

I created a new directory locally and did:

  • git clone into home directory
  • How to run git p4 submit on a bare repo?
  • Having trouble setting up dev server for Django and website
  • What exactly is a content level merge?
  • How to prevent git commit tool from closing after a commit?
  • Best practice for automating Php project builds using Visual Studio Ultimate/Online and Git
  • [ ] git clone git@github.com:{username}/{projectname}.git
    

    Then I created a new branch named my_test with

    [ ] git branch my_test
    

    and switched to it.

    [ ] git checkout my_test
    

    Then I merged it from my test branch of my public repository with

    [ ] git merge origin/test
    

    and it resulted in a fast forward.

    I made some changes and committed them.
    Then I tried to push the local my_test branch to the public test branch at github with

    [ ] git push git@github.com:{username}/{projectname}.git test 
    

    but I got this error:

    error: src refspec test does not match any.
    fatal: The remote end hung up unexpectedly
    error: failed to push some refs to 'git@github.com:{username}/{projectname}.git
    

    What am I doing wrong ?

  • how to install zend in xmpp in windows 8
  • git bundle a range of commits
  • How to integrate Sublime Text with GitHub?
  • Git push origin master fatal error: Permission to railstutorial/first_app.git denied
  • git merging two commits
  • Git & Intellij, How do I commit only parts of a changed file
  • 5 Solutions collect form web for “Error when “git push” to github”

    Perhaps try:

    git push git@github.com:{username}/{projectname}.git HEAD:test
    

    The format of the last parameter on that command line is a refspec which is a source ref followed by a colon and then the destination ref. You can also use your local branch name (my_test) instead of HEAD to be certain you’re pushing the correct branch.

    The documentation for git push has more detail on this parameter.

    Also, you don’t need to type out the whole url each time you want to push. When you ran the clone, git saved that URL as ‘origin’, that’s why you can run something like ‘merge origin/test’ – it means the ‘test’ branch on your ‘origin’ server. So, the simplest way to push to your server in that case would be:

    git push origin my_test:test
    

    That will push your local ‘my_test’ branch to the ‘test’ branch on your ‘origin’ server. If you had named your local branch the same as the branch on the server, then the colon is not neccesary, you can simply do:

    git push origin test
    

    I think here you will need to set up branch tracking. Please run the following to enable tracking

    git branch --track my_test origin/my_test
    

    To test

    git push -u origin my_test
    git pull origin my_test
    

    This error also comes up if you try to push to a new repository without having committed anything first. Try:

    git add -A
    git commit -am 'Initial commit'
    

    And then try your push again.

    You need to make sure that your local repository have the same name as your remote repository you’re trying to push.

    First, change repository using git branch -m “test” so that “my_test” would be “test”.
    Second, just git push origin test

    Git Baby is a git and github fan, let's start git clone.