# RE: Simple shortcut for "git push --set-upstream origin newBranchName"

7 messages from 2019-05-31 to 2019-06-03. Participants: Cliff Schomburg, Patryk Obara, Denton Liu.
Thread: https://gitlist.dev/t/51208

## Cliff Schomburg, 2019-05-31 14:45

Subject: RE: Simple shortcut for "git push --set-upstream origin newBranchName"
Message-ID: <BN8PR21MB1156F7F3E7EFF9C8A60F33D0B7190@BN8PR21MB1156.namprd21.prod.outlook.com>
URL: https://gitlist.dev/e/BN8PR21MB1156F7F3E7EFF9C8A60F33D0B7190%40BN8PR21MB1156.namprd21.prod.outlook.com
In-Reply-To: <BN8PR21MB1156DA1893F64814F1BE8709B7180@BN8PR21MB1156.namprd21.prod.outlook.com>

```
Resending as plain text

From: Cliff Schomburg 
Sent: Thursday, May 30, 2019 6:29 PM
To: git@vger.kernel.org
Subject: Simple shortcut for "git push --set-upstream origin newBranchName"

Hi all,

This is more of a suggestion than a bug report.

I create new topic branches quite frequently and push them into the remote repo (origin).

It's a bit of a hassle to type "git push -set-upstream origin newBranchName" each and every time I want to push a new branch.

I'm proposing a shortcut for this command.  Perhaps "git push -default" or "git push -new-branch" which could be shortened to "git push -d" or "git push -nb" or something.

Based on the man-page for push, it looks like this could be an alias for:
    "git push -set-upstream origin HEAD"
In which case HEAD should always be the current branch name.

Thoughts?  Concerns?

Thanks,
Cliff


```

## Patryk Obara, 2019-05-31 14:51

Subject: Re: Simple shortcut for "git push --set-upstream origin newBranchName"
Message-ID: <ac62f96f-0ebc-2dff-3365-781e6b9142a3@gmail.com>
URL: https://gitlist.dev/e/ac62f96f-0ebc-2dff-3365-781e6b9142a3%40gmail.com
In-Reply-To: <BN8PR21MB1156F7F3E7EFF9C8A60F33D0B7190@BN8PR21MB1156.namprd21.prod.outlook.com>

```
On 31/05/2019 16:45, Cliff Schomburg wrote:
> I'm proposing a shortcut for this command.

What's wrong with "$ git push -u origin branch"?

--
Patryk Obara

```

## Cliff Schomburg, 2019-05-31 14:56

Subject: RE: Simple shortcut for "git push --set-upstream origin newBranchName"
Message-ID: <BN8PR21MB115693C381F65E97AB65FA18B7190@BN8PR21MB1156.namprd21.prod.outlook.com>
URL: https://gitlist.dev/e/BN8PR21MB115693C381F65E97AB65FA18B7190%40BN8PR21MB1156.namprd21.prod.outlook.com
In-Reply-To: <ac62f96f-0ebc-2dff-3365-781e6b9142a3@gmail.com>

```
Wow, I did not see that in the man pages... but I see it now.  Thanks!

So I guess I would change my ask to this:

"git push -u"

Should default to "origin branch" if no parameters are provided.  Thoughts?

Thanks,
Cliff

-----Original Message-----
From: Patryk Obara <dreamer.tan@gmail.com> 
Sent: Friday, May 31, 2019 10:51 AM
To: Cliff Schomburg <clisc@microsoft.com>; git@vger.kernel.org
Subject: Re: Simple shortcut for "git push --set-upstream origin newBranchName"

On 31/05/2019 16:45, Cliff Schomburg wrote:
> I'm proposing a shortcut for this command.

What's wrong with "$ git push -u origin branch"?

--
Patryk Obara

```

## Patryk Obara, 2019-05-31 15:05

Subject: Re: Simple shortcut for "git push --set-upstream origin newBranchName"
Message-ID: <ebc03b4e-daf8-d47f-94ca-a4a549589773@gmail.com>
URL: https://gitlist.dev/e/ebc03b4e-daf8-d47f-94ca-a4a549589773%40gmail.com
In-Reply-To: <BN8PR21MB115693C381F65E97AB65FA18B7190@BN8PR21MB1156.namprd21.prod.outlook.com>

```
On 31/05/2019 16:56, Cliff Schomburg wrote:
> Wow, I did not see that in the man pages... but I see it now.  Thanks!
> 
> So I guess I would change my ask to this:
> 
> "git push -u"
> 
> Should default to "origin branch" if no parameters are provided.

I think most people will agree, considering it already works this way :)

The default behaviour of git push changed in Git 2.0, perhaps you were 
reading some old tutorial. You can configure it to match your 
preferences by changing push.default value in your git config:

https://git-scm.com/docs/git-config#Documentation/git-config.txt-pushdefault

--
Patryk Obara

```

## Denton Liu, 2019-05-31 15:11

Subject: Re: Simple shortcut for "git push --set-upstream origin newBranchName"
Message-ID: <20190531151126.GA3465@archbookpro.localdomain>
URL: https://gitlist.dev/e/20190531151126.GA3465%40archbookpro.localdomain
In-Reply-To: <BN8PR21MB115693C381F65E97AB65FA18B7190@BN8PR21MB1156.namprd21.prod.outlook.com>

```
On Fri, May 31, 2019 at 02:56:12PM +0000, Cliff Schomburg wrote:
> Wow, I did not see that in the man pages... but I see it now.  Thanks!
> 
> So I guess I would change my ask to this:
> 
> "git push -u"
> 
> Should default to "origin branch" if no parameters are provided.  Thoughts?

I'll do you one better. You can run

	$ git push -u origin HEAD

and HEAD will mean the current branch, so you'll only need to specify
the remote (in our case, origin).

Perhaps you could alias that to something like `git push-up`.

> 
> Thanks,
> Cliff
> 
> -----Original Message-----
> From: Patryk Obara <dreamer.tan@gmail.com> 
> Sent: Friday, May 31, 2019 10:51 AM
> To: Cliff Schomburg <clisc@microsoft.com>; git@vger.kernel.org
> Subject: Re: Simple shortcut for "git push --set-upstream origin newBranchName"
> 
> On 31/05/2019 16:45, Cliff Schomburg wrote:
> > I'm proposing a shortcut for this command.
> 
> What's wrong with "$ git push -u origin branch"?
> 
> --
> Patryk Obara

```

## Cliff Schomburg, 2019-05-31 15:13

Subject: RE: Simple shortcut for "git push --set-upstream origin newBranchName"
Message-ID: <BN8PR21MB1156D785177A40EA7D8341ABB7190@BN8PR21MB1156.namprd21.prod.outlook.com>
URL: https://gitlist.dev/e/BN8PR21MB1156D785177A40EA7D8341ABB7190%40BN8PR21MB1156.namprd21.prod.outlook.com
In-Reply-To: <ebc03b4e-daf8-d47f-94ca-a4a549589773@gmail.com>

```
Thanks, Patryk.  It's always nice to see the feature I want is already implemented!  😊

-----Original Message-----
From: Patryk Obara <dreamer.tan@gmail.com> 
Sent: Friday, May 31, 2019 11:05 AM
To: Cliff Schomburg <clisc@microsoft.com>; git@vger.kernel.org
Subject: Re: Simple shortcut for "git push --set-upstream origin newBranchName"

On 31/05/2019 16:56, Cliff Schomburg wrote:
> Wow, I did not see that in the man pages... but I see it now.  Thanks!
> 
> So I guess I would change my ask to this:
> 
> "git push -u"
> 
> Should default to "origin branch" if no parameters are provided.

I think most people will agree, considering it already works this way :)

The default behaviour of git push changed in Git 2.0, perhaps you were reading some old tutorial. You can configure it to match your preferences by changing push.default value in your git config:

https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit-scm.com%2Fdocs%2Fgit-config%23Documentation%2Fgit-config.txt-pushdefault&amp;data=02%7C01%7Cclisc%40microsoft.com%7Cf52d699c3fc149d20de508d6e5d96a4c%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636949119289770838&amp;sdata=K2NezwOWzZrqsU7l8GybjbJuwmRnC2llT77UhvF%2B8RU%3D&amp;reserved=0

--
Patryk Obara

```

## Cliff Schomburg, 2019-06-03 21:34

Subject: RE: Simple shortcut for "git push --set-upstream origin newBranchName"
Message-ID: <BN8PR21MB11569B2A49F0ACB69E883458B7140@BN8PR21MB1156.namprd21.prod.outlook.com>
URL: https://gitlist.dev/e/BN8PR21MB11569B2A49F0ACB69E883458B7140%40BN8PR21MB1156.namprd21.prod.outlook.com
In-Reply-To: <BN8PR21MB1156D785177A40EA7D8341ABB7190@BN8PR21MB1156.namprd21.prod.outlook.com>

```
So I gave this a try and it seems not to be behaving as expected:

>git push -u
fatal: The current branch {branchName} has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin {branchName}

I'm using Git for Windows in a Windows CMD prompt, if that matters at all.

Thanks,m
Cliff


-----Original Message-----
From: Cliff Schomburg 
Sent: Friday, May 31, 2019 11:13 AM
To: Patryk Obara <dreamer.tan@gmail.com>; git@vger.kernel.org
Subject: RE: Simple shortcut for "git push --set-upstream origin newBranchName"

Thanks, Patryk.  It's always nice to see the feature I want is already implemented!  😊

-----Original Message-----
From: Patryk Obara <dreamer.tan@gmail.com> 
Sent: Friday, May 31, 2019 11:05 AM
To: Cliff Schomburg <clisc@microsoft.com>; git@vger.kernel.org
Subject: Re: Simple shortcut for "git push --set-upstream origin newBranchName"

On 31/05/2019 16:56, Cliff Schomburg wrote:
> Wow, I did not see that in the man pages... but I see it now.  Thanks!
> 
> So I guess I would change my ask to this:
> 
> "git push -u"
> 
> Should default to "origin branch" if no parameters are provided.

I think most people will agree, considering it already works this way :)

The default behaviour of git push changed in Git 2.0, perhaps you were reading some old tutorial. You can configure it to match your preferences by changing push.default value in your git config:

https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit-scm.com%2Fdocs%2Fgit-config%23Documentation%2Fgit-config.txt-pushdefault&amp;data=02%7C01%7Cclisc%40microsoft.com%7Cf52d699c3fc149d20de508d6e5d96a4c%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636949119289770838&amp;sdata=K2NezwOWzZrqsU7l8GybjbJuwmRnC2llT77UhvF%2B8RU%3D&amp;reserved=0

--
Patryk Obara

```
