git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* pushing branches
@ 2012-07-20 15:26 Thiago Farina
  2012-07-20 15:46 ` Junio C Hamano
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Thiago Farina @ 2012-07-20 15:26 UTC (permalink / raw
  To: Git Mailing List

Hi,

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.
Everything up-to-date.

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

Thanks,

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: pushing branches
  2012-07-20 15:26 pushing branches Thiago Farina
@ 2012-07-20 15:46 ` Junio C Hamano
  2012-07-20 15:49   ` Thiago Farina
  2012-07-20 15:46 ` PJ Weisberg
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 13+ messages in thread
From: Junio C Hamano @ 2012-07-20 15:46 UTC (permalink / raw
  To: Thiago Farina; +Cc: Git Mailing List

Thiago Farina <tfransosi@gmail.com> writes:

> 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

"git push origin master" is a short-hand for "git push origin
refs/heads/master:refs/heads/master" to update their master branch
with what you have in your master branch. 

See output from

    $ git push --help

for details.

I think you are trying to update, while on your feature-work branch,
their master with your feature-work branch (or more generally, the
current HEAD), so

    $ git push origin HEAD:master

is perhaps what you are looking for?    

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: pushing branches
  2012-07-20 15:26 pushing branches Thiago Farina
  2012-07-20 15:46 ` Junio C Hamano
@ 2012-07-20 15:46 ` PJ Weisberg
  2012-07-20 15:49 ` Konstantin Khomoutov
  2012-07-20 15:53 ` Matthieu Moy
  3 siblings, 0 replies; 13+ messages in thread
From: PJ Weisberg @ 2012-07-20 15:46 UTC (permalink / raw
  To: Thiago Farina; +Cc: Git Mailing List

On Fri, Jul 20, 2012 at 8:26 AM, Thiago Farina <tfransosi@gmail.com> wrote:
> Hi,
>
> 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.
> Everything up-to-date.
>
> $ git checkout master
> $ git push origin feature-work # Now the branch is pushed.

???

I must be missing something.  It looks like the reason it didn't push
feature-work the first time is because you told it to push master
instead.

-PJ

Gehm's Corollary to Clark's Law: Any technology distinguishable from
magic is insufficiently advanced.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: pushing branches
  2012-07-20 15:26 pushing branches Thiago Farina
  2012-07-20 15:46 ` Junio C Hamano
  2012-07-20 15:46 ` PJ Weisberg
@ 2012-07-20 15:49 ` Konstantin Khomoutov
  2012-07-20 15:53 ` Matthieu Moy
  3 siblings, 0 replies; 13+ messages in thread
From: Konstantin Khomoutov @ 2012-07-20 15:49 UTC (permalink / raw
  To: Thiago Farina; +Cc: Git Mailing List

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

> 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.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: pushing branches
  2012-07-20 15:46 ` Junio C Hamano
@ 2012-07-20 15:49   ` Thiago Farina
  2012-07-20 19:19     ` PJ Weisberg
  0 siblings, 1 reply; 13+ messages in thread
From: Thiago Farina @ 2012-07-20 15:49 UTC (permalink / raw
  To: Junio C Hamano; +Cc: Git Mailing List

On Fri, Jul 20, 2012 at 12:46 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Thiago Farina <tfransosi@gmail.com> writes:
>
>> 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
>
> "git push origin master" is a short-hand for "git push origin
> refs/heads/master:refs/heads/master" to update their master branch
> with what you have in your master branch.
>
> See output from
>
>     $ git push --help
>
> for details.
>
> I think you are trying to update, while on your feature-work branch,
> their master with your feature-work branch (or more generally, the
> current HEAD), so
>
>     $ git push origin HEAD:master
>
> is perhaps what you are looking for?

What I'm looking for is to upload/create the remote branch in github
from inside my local branch, without having to checkout master in
order to do so.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: pushing branches
  2012-07-20 15:26 pushing branches Thiago Farina
                   ` (2 preceding siblings ...)
  2012-07-20 15:49 ` Konstantin Khomoutov
@ 2012-07-20 15:53 ` Matthieu Moy
  3 siblings, 0 replies; 13+ messages in thread
From: Matthieu Moy @ 2012-07-20 15:53 UTC (permalink / raw
  To: Thiago Farina; +Cc: Git Mailing List

Thiago Farina <tfransosi@gmail.com> writes:

> $ 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.
> Everything up-to-date.

If your workflow is to push one branch at a time, and you have the same
naming locally and remotely (i.e. your local branch feature-work should
be pushed as feature-work on github), then you probably want to set the
variable 'push.default' to either 'current', 'upstream' or 'simple' if
you use the last version of Git. Read about it there:

  http://git-scm.com/docs/git-config

(search push.default)

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: pushing branches
  2012-07-20 15:49   ` Thiago Farina
@ 2012-07-20 19:19     ` PJ Weisberg
  2012-07-21  1:40       ` Thiago Farina
  0 siblings, 1 reply; 13+ messages in thread
From: PJ Weisberg @ 2012-07-20 19:19 UTC (permalink / raw
  To: Thiago Farina; +Cc: Junio C Hamano, Git Mailing List

On Fri, Jul 20, 2012 at 8:49 AM, Thiago Farina <tfransosi@gmail.com> wrote:

> What I'm looking for is to upload/create the remote branch in github
> from inside my local branch, without having to checkout master in
> order to do so.

In that case, do exactly what you did, except don't checkout master.

-PJ

Gehm's Corollary to Clark's Law: Any technology distinguishable from
magic is insufficiently advanced.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: pushing branches
  2012-07-20 19:19     ` PJ Weisberg
@ 2012-07-21  1:40       ` Thiago Farina
  2012-07-21  1:58         ` PJ Weisberg
  0 siblings, 1 reply; 13+ messages in thread
From: Thiago Farina @ 2012-07-21  1:40 UTC (permalink / raw
  To: PJ Weisberg; +Cc: Junio C Hamano, Git Mailing List

On Fri, Jul 20, 2012 at 4:19 PM, PJ Weisberg
<pj@irregularexpressions.net> wrote:
> On Fri, Jul 20, 2012 at 8:49 AM, Thiago Farina <tfransosi@gmail.com> wrote:
>
>> What I'm looking for is to upload/create the remote branch in github
>> from inside my local branch, without having to checkout master in
>> order to do so.
>
> In that case, do exactly what you did, except don't checkout master.
>
Why you suggest that? If I demonstrated that origin master or just
origin in the current branch doesn't do what I want, i.e, push it to
github.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: pushing branches
  2012-07-21  1:40       ` Thiago Farina
@ 2012-07-21  1:58         ` PJ Weisberg
  2012-07-21  2:10           ` Thiago Farina
  0 siblings, 1 reply; 13+ messages in thread
From: PJ Weisberg @ 2012-07-21  1:58 UTC (permalink / raw
  To: Thiago Farina; +Cc: Junio C Hamano, Git Mailing List

On Fri, Jul 20, 2012 at 6:40 PM, Thiago Farina <tfransosi@gmail.com> wrote:
> On Fri, Jul 20, 2012 at 4:19 PM, PJ Weisberg
> <pj@irregularexpressions.net> wrote:
>> On Fri, Jul 20, 2012 at 8:49 AM, Thiago Farina <tfransosi@gmail.com> wrote:
>>
>>> What I'm looking for is to upload/create the remote branch in github
>>> from inside my local branch, without having to checkout master in
>>> order to do so.
>>
>> In that case, do exactly what you did, except don't checkout master.
>>
> Why you suggest that? If I demonstrated that origin master or just
> origin in the current branch doesn't do what I want, i.e, push it to
> github.

In your original email, you had one command that did what you wanted
and one that didn't.

$ git push origin master
$ git push origin feature-work

Can you spot the difference between them?

Like Konstantin said, you can look into the different options for
push.default, but don't expect Git to push one branch when you told it
to push another.

-PJ

Gehm's Corollary to Clark's Law: Any technology distinguishable from
magic is insufficiently advanced.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: pushing branches
  2012-07-21  1:58         ` PJ Weisberg
@ 2012-07-21  2:10           ` Thiago Farina
  2012-07-21 19:33             ` Junio C Hamano
  0 siblings, 1 reply; 13+ messages in thread
From: Thiago Farina @ 2012-07-21  2:10 UTC (permalink / raw
  To: PJ Weisberg; +Cc: Junio C Hamano, Git Mailing List

On Fri, Jul 20, 2012 at 10:58 PM, PJ Weisberg
<pj@irregularexpressions.net> wrote:
> In your original email, you had one command that did what you wanted
> and one that didn't.
>
> $ git push origin master
> $ git push origin feature-work
>
> Can you spot the difference between them?
>
Do'h, now I can see the idiocy that I was doing.

If I'm understanding this better,
$ git push origin master
tells git to push to remote origin, the contents of my master branch.

And then,

$ git push origin feature-work
tells git to push to remote origin to push the contents of feature-work branch.

Hence does not make sense to ask git to do "push origin master" while
inside feature-work branch.

> Like Konstantin said, you can look into the different options for
> push.default, but don't expect Git to push one branch when you told it
> to push another.
>
> -PJ
>
> Gehm's Corollary to Clark's Law: Any technology distinguishable from
> magic is insufficiently advanced.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: pushing branches
  2012-07-21  2:10           ` Thiago Farina
@ 2012-07-21 19:33             ` Junio C Hamano
  2012-07-22  2:54               ` Thiago Farina
  0 siblings, 1 reply; 13+ messages in thread
From: Junio C Hamano @ 2012-07-21 19:33 UTC (permalink / raw
  To: Thiago Farina; +Cc: PJ Weisberg, Git Mailing List

Thiago Farina <tfransosi@gmail.com> writes:

> Do'h, now I can see the idiocy that I was doing.
>
> If I'm understanding this better,
> $ git push origin master
> tells git to push to remote origin, the contents of my master branch.

Yes, add "to the 'master' at the 'origin'" at the end of the
sentence and you are perfect.

> And then,
>
> $ git push origin feature-work
> tells git to push to remote origin to push the contents of feature-work branch.

Yes.

> Hence does not make sense to ask git to do "push origin master" while
> inside feature-work branch.

No.  As long as you know your master is ready and suitable to be
published when you ask "push", the command perfectly makes sense; it
does not matter on what branch you are on.

You may say

	$ git checkout master
        ... work work work ...
        $ make test
        ... ahh, perfection! ...
        $ git checkout -b feature
        ... let's build a bit more ..
        ... while I am having fun, let's not forget to push the
        ... part that is already solid out
        $ git push origin master

and that is perfectly fine without "git checkout master" before
pushing (and "git checkout feature" after to come back to what you
were doing).

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: pushing branches
  2012-07-21 19:33             ` Junio C Hamano
@ 2012-07-22  2:54               ` Thiago Farina
  2012-07-22 18:40                 ` Junio C Hamano
  0 siblings, 1 reply; 13+ messages in thread
From: Thiago Farina @ 2012-07-22  2:54 UTC (permalink / raw
  To: Junio C Hamano; +Cc: PJ Weisberg, Git Mailing List

On Sat, Jul 21, 2012 at 4:33 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Yes.
>
>> Hence does not make sense to ask git to do "push origin master" while
>> inside feature-work branch.
>
> No.  As long as you know your master is ready and suitable to be
> published when you ask "push", the command perfectly makes sense; it
> does not matter on what branch you are on.
>
> You may say
>
>         $ git checkout master
>         ... work work work ...
>         $ make test
>         ... ahh, perfection! ...
>         $ git checkout -b feature
>         ... let's build a bit more ..
>         ... while I am having fun, let's not forget to push the
>         ... part that is already solid out
>         $ git push origin master
>
> and that is perfectly fine without "git checkout master" before
> pushing (and "git checkout feature" after to come back to what you
> were doing).
In my case it wouldn't because I do not modify my master branch, I
just fetch upstream, merge upstream/master into my local master branch
and switch to feature-work, then git push origin master will always
give me "Everything up-to-date" I suppose (that is what always happen
in my case/workflow).

And just learned, the answer to my question is, while in feature-work
branch, 'git push origin feature-work'. Which does what I wanted.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: pushing branches
  2012-07-22  2:54               ` Thiago Farina
@ 2012-07-22 18:40                 ` Junio C Hamano
  0 siblings, 0 replies; 13+ messages in thread
From: Junio C Hamano @ 2012-07-22 18:40 UTC (permalink / raw
  To: Thiago Farina; +Cc: PJ Weisberg, Git Mailing List

Thiago Farina <tfransosi@gmail.com> writes:

> On Sat, Jul 21, 2012 at 4:33 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> Yes.
>>
>>> Hence does not make sense to ask git to do "push origin master" while
>>> inside feature-work branch.
>> ...
>> No.  As long as you know your master is ready and suitable to be
>> published when you ask "push", the command perfectly makes sense; it
>> does not matter on what branch you are on.
>> ...
> In my case it wouldn't because I do not modify my master branch, I
> just fetch upstream, merge upstream/master into my local master branch
> and switch to feature-work, then git push origin master will always
> give me "Everything up-to-date" I suppose (that is what always happen
> in my case/workflow).

It would not make _any_ sense to ask "git push origin master"
regardless of which branch you are on if that is the case, as you
are not modifying, then.

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2012-07-22 18:41 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-20 15:26 pushing branches Thiago Farina
2012-07-20 15:46 ` Junio C Hamano
2012-07-20 15:49   ` Thiago Farina
2012-07-20 19:19     ` PJ Weisberg
2012-07-21  1:40       ` Thiago Farina
2012-07-21  1:58         ` PJ Weisberg
2012-07-21  2:10           ` Thiago Farina
2012-07-21 19:33             ` Junio C Hamano
2012-07-22  2:54               ` Thiago Farina
2012-07-22 18:40                 ` Junio C Hamano
2012-07-20 15:46 ` PJ Weisberg
2012-07-20 15:49 ` Konstantin Khomoutov
2012-07-20 15:53 ` Matthieu Moy

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).