threads / discuss / 21366

git push interface inconsistency

Subject: git push interface inconsistency

## tl;dr

3 messages between Oct 26, 2009 and Oct 26, 2009.

replies: 2people: 2as markdown or json

Eugene Sajine· Oct 26, 2009, 22:25 UTC · lore
Hi,
I have a question:
Why I can't do
$ git push my_tag

It will fail because the remote is not specified, even if there is only one origin remote

but can do
$ git push --tags
and it will push tags to origin...

Thanks, Eugene

Avery Pennarun· Oct 26, 2009, 22:31 UTC · re: Eugene Sajine · lore

Re: git push interface inconsistency

On Mon, Oct 26, 2009 at 6:25 PM, Eugene Sajine <euguess@gmail.com> wrote:
Show 14 quoted lines
> I have a question:
>
> Why I can't do
>
> $ git push my_tag
>
> It will fail because the remote is not specified, even if there is
> only one origin remote
>
> but can do
>
> $ git push --tags
>
> and it will push tags to origin...

Because 'my_tag' is interpreted as the name or URL of the remote, not as a branch name. You can do "git push origin" and it will guess the branch name(s) to push, but because of that, the one-parameter push can't *also* be used to guess the remote name.

In contrast, --tags is a flag, so it's actually the zero-parameter version of push, which assumes 'origin' and then guesses the branch name (and --tags changes the guessed result).

Hope that helps.
Have fun,
Avery
Eugene Sajine· Oct 26, 2009, 23:39 UTC · re: Avery Pennarun · lore

Re: git push interface inconsistency

Got it.
Thanks!
On Mon, Oct 26, 2009 at 6:31 PM, Avery Pennarun <apenwarr@gmail.com> wrote:
Show 31 quoted lines
> On Mon, Oct 26, 2009 at 6:25 PM, Eugene Sajine <euguess@gmail.com> wrote:
>> I have a question:
>>
>> Why I can't do
>>
>> $ git push my_tag
>>
>> It will fail because the remote is not specified, even if there is
>> only one origin remote
>>
>> but can do
>>
>> $ git push --tags
>>
>> and it will push tags to origin...
>
> Because 'my_tag' is interpreted as the name or URL of the remote, not
> as a branch name.  You can do "git push origin" and it will guess the
> branch name(s) to push, but because of that, the one-parameter push
> can't *also* be used to guess the remote name.
>
> In contrast, --tags is a flag, so it's actually the zero-parameter
> version of push, which assumes 'origin' and then guesses the branch
> name (and --tags changes the guessed result).
>
> Hope that helps.
>
> Have fun,
>
> Avery
>

← back to recent threads