local and remote branch need to match names for git push?

It’d be awesome if someone helped me get this.

Say I’m working in master or in a branch called MyBranch and I want to push the changes I just committed to a new github branch. When I do

  • How Do I 'git fetch' and 'git merge' from a Remote Tracking Branch (like 'git pull')
  • Do I need Git to use Github in JetBrains IntelliJ IDEA?
  • Does GitHub garbage collect dangling commits referenced in pull requests?
  • Remove Credentials from GIT in Jenkins
  • Line endings in git
  • Whitespace in .gitattributes patterns
  • git push origin RemoteBranch

    it’ll say something like

    error: src refspec RemoteBranch does not match any.
    error: failed to push some refs to 'git@github.com:bla/bla.git'

    1) Why is that? It seems that only way to replicate a commit to a remote branch is to make absolutely sure that their names are a perfect match. Basically I have to locally perform a git branch RemoteBranch, and then I can do a push just fine.

    2) How can I see the full list of remote branches?

    git branch -a


    git branch -r

    will only show the branches whose match I have on my local repo as opposed to all of the branches available on github.

    Thank you!

  • git - setting path variable
  • Why doesn't gitignore work in this case?
  • Remove commit for good
  • Import a svn repo to git from a given point in time
  • Error in deleting/addind file from appharbor using git “Unable to create 'f:/git/xyz/WorkerProcess/.git/index.lock': File exists”
  • is it possible to generate a graph in Visual Studio Online to show coders' contributions?
  • 2 Solutions collect form web for “local and remote branch need to match names for git push?”

    If you would have a look at the man page, you would find out how.

    You could use: git push <remote> <local-branch>:<remote-branch>

    You must first create the local branch before you can push it:

    git checkout -b RemoteBranch
    git push -u origin RemoteBranch

    The -u option is to automatically setup RemoteBranch to track origin/RemoteBranch

    Or, if you are on master and would like to push up master as a new branch:

    git push origin master:RemoteBranch
    Git Baby is a git and github fan, let's start git clone.