Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: How to push from "no branch" to a new remote branch?

I did:

git co upstream/master  # To no branch.
<then did a trivial edit on some file...>
git commit -a -m "Trivial edit"
git push origin NewBranch

But got this:

$ git push origin ignore-netbeans-config
error: src refspec ignore-netbeans-config does not match any.

Can I push to a new branch without creating a local one?

like image 583
Ondra Žižka Avatar asked Nov 10 '11 16:11

Ondra Žižka


People also ask

How do I push to a different remote branch?

In order to push your branch to another remote branch, use the “git push” command and specify the remote name, the name of your local branch as the name of the remote branch.

How do I specify which branch to push to?

You will usually push your local branch to a remote branch of the same name—but not always. To push to a branch of a different name, you just need to specify the branch you want to push and the name of the branch you want to push to separated by a colon ( : ).

Can I push a branch without commit?

No, you must make a commit before you can push. What is being pushed is the commit (or commits).


1 Answers

try

git push origin HEAD:refs/heads/ignore-netbeans-config
like image 168
max Avatar answered Oct 11 '22 15:10

max