git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: pushing branches

From
KKKonstantin Khomoutov <flatworm@users.sourceforge.net>
Date
Jul 20, 2012, 15:49 UTC
Message-ID
<20120720194905.9929a30ee42fd73cf62e7992@domain007.com>
In-Reply-To
<CACnwZYdqP_ptj0++dj5NkCoKWKHiLEj+c0t7zrmNidkHsyzMgw@mail.gmail.com>

On Fri, 20 Jul 2012 12:26:09 -0300 Thiago Farina <tfransosi@gmail.com> wrote:

Show 12 quoted lines
> How can I push a working branch to github inside it?
> 
> E.g:
> 
> # On master:
> $ git checkout -b feature-work
> 
> # On feature-work
> # vi, hack, commit, ready to push
> $ git push origin master # here I expected it would working pushing my
> commits to a feature-work branch in github. Or if I omit master it
> gives me a [rejected] error.

$ git push origin master means "update the branch 'master' in the remote repository with the contents of the branch 'master' in the local repository". Read the "git push" manual.

> $ git checkout master
> $ git push origin feature-work # Now the branch is pushed.

Sure, but it has nothing to do with the previous checkout command: you just told Git to push the contents of your local branch "feature-work" to a remote branch "feature-work" which presumably does not exist and gets created as a result of your push.

If you want to update the remote "master" branch with the contents of your local "feature-work" branch, do $ git push origin feature-work:master

As stated below, you should really read the git push manual and reading through the appropriate sections of the http://git-scm.com/book is also highly advised.

Also consider reading about the "push.default" configuration variable in the git config manual--this might save you from scratching your head when you try to do simple `git push origin` without specifying any branches: here again your expectation might differ from the Git defaults.

Previous: PJ WeisbergNext: Matthieu Moy
Message 12 of 13 in “pushing branches”
  1. Thiago FarinaJul 20, 2012
  2. Junio C HamanoJul 20, 2012
  3. Thiago FarinaJul 20, 2012
  4. PJ WeisbergJul 20, 2012
  5. Thiago FarinaJul 21, 2012
  6. PJ WeisbergJul 21, 2012
  7. Thiago FarinaJul 21, 2012
  8. Junio C HamanoJul 21, 2012
  9. Thiago FarinaJul 22, 2012
  10. Junio C HamanoJul 22, 2012
  11. PJ WeisbergJul 20, 2012
  12. Konstantin KhomoutovJul 20, 2012
  13. Matthieu MoyJul 20, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.