git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Convenient shortcut to push delete current branch?
@ 2015-10-01 16:43 Robert Dailey
  2015-10-01 18:22 ` Jacob Keller
  0 siblings, 1 reply; 4+ messages in thread
From: Robert Dailey @ 2015-10-01 16:43 UTC (permalink / raw)
  To: Git

For convenient pushing of current branch, git supports this syntax:

$ git push origin HEAD

This will push your current branch up. However, is there such a
shortcut for *deleting* the branch? The only goal here is to avoid
having to type the branch name in the push command. Normally I rely on
tab completion but we have tons of branches, all which start with some
prefix mixed with numbers, so it becomes cumbersome to rely on tab
completion. Ideally I'd like to be able to do:

$ git push --delete origin HEAD
$ git push origin :HEAD

Is there a syntax like this available?

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

* Re: Convenient shortcut to push delete current branch?
  2015-10-01 16:43 Convenient shortcut to push delete current branch? Robert Dailey
@ 2015-10-01 18:22 ` Jacob Keller
  2015-10-01 18:37   ` Robert Dailey
  0 siblings, 1 reply; 4+ messages in thread
From: Jacob Keller @ 2015-10-01 18:22 UTC (permalink / raw)
  To: Robert Dailey; +Cc: Git

On Thu, Oct 1, 2015 at 9:43 AM, Robert Dailey <rcdailey.lists@gmail.com> wrote:
> For convenient pushing of current branch, git supports this syntax:
>
> $ git push origin HEAD
>
> This will push your current branch up. However, is there such a
> shortcut for *deleting* the branch? The only goal here is to avoid
> having to type the branch name in the push command. Normally I rely on
> tab completion but we have tons of branches, all which start with some
> prefix mixed with numbers, so it becomes cumbersome to rely on tab
> completion. Ideally I'd like to be able to do:
>
> $ git push --delete origin HEAD
> $ git push origin :HEAD
>
> Is there a syntax like this available?

You can do

git push origin:<branchname>

but I don't believe HEAD is supported. It might be valuable to extend
push to have a --delete option which would maybe be useful for those
who didn't learn the full refspec syntax.

I don't think git push origin :HEAD makes too much sense, since that's
on the remote side of a refspec, and you want it interpreted
locally... I suppose it makes sense somewhat, but other refspecs with
HEAD on the remote side of the refspec don't really make sense, where
as HEAD always makes sense on the local side of the refspec.

Regards,
Jake

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

* Re: Convenient shortcut to push delete current branch?
  2015-10-01 18:22 ` Jacob Keller
@ 2015-10-01 18:37   ` Robert Dailey
  2015-10-02 13:33     ` Mike Rappazzo
  0 siblings, 1 reply; 4+ messages in thread
From: Robert Dailey @ 2015-10-01 18:37 UTC (permalink / raw)
  To: Jacob Keller; +Cc: Git

On Thu, Oct 1, 2015 at 1:22 PM, Jacob Keller <jacob.keller@gmail.com> wrote:
> On Thu, Oct 1, 2015 at 9:43 AM, Robert Dailey <rcdailey.lists@gmail.com> wrote:
>> For convenient pushing of current branch, git supports this syntax:
>>
>> $ git push origin HEAD
>>
>> This will push your current branch up. However, is there such a
>> shortcut for *deleting* the branch? The only goal here is to avoid
>> having to type the branch name in the push command. Normally I rely on
>> tab completion but we have tons of branches, all which start with some
>> prefix mixed with numbers, so it becomes cumbersome to rely on tab
>> completion. Ideally I'd like to be able to do:
>>
>> $ git push --delete origin HEAD
>> $ git push origin :HEAD
>>
>> Is there a syntax like this available?
>
> You can do
>
> git push origin:<branchname>
>
> but I don't believe HEAD is supported. It might be valuable to extend
> push to have a --delete option which would maybe be useful for those
> who didn't learn the full refspec syntax.

Push already has a --delete option.

> I don't think git push origin :HEAD makes too much sense, since that's
> on the remote side of a refspec, and you want it interpreted
> locally... I suppose it makes sense somewhat, but other refspecs with
> HEAD on the remote side of the refspec don't really make sense, where
> as HEAD always makes sense on the local side of the refspec.

HEAD makes sense on the remote side if you think of it like an alias:

HEAD -> branch-name -> SHA1

HEAD simply points to branch-name. It makes sense for git to assume
that we should never do anything with real HEAD ref on the remote
side, and instead treat it as a substitution for the remote name. My
assumption may not be correct, but at the very least it should be a
niche case.

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

* Re: Convenient shortcut to push delete current branch?
  2015-10-01 18:37   ` Robert Dailey
@ 2015-10-02 13:33     ` Mike Rappazzo
  0 siblings, 0 replies; 4+ messages in thread
From: Mike Rappazzo @ 2015-10-02 13:33 UTC (permalink / raw)
  To: Robert Dailey; +Cc: Jacob Keller, Git

On Thu, Oct 1, 2015 at 2:37 PM, Robert Dailey <rcdailey.lists@gmail.com> wrote:
> On Thu, Oct 1, 2015 at 1:22 PM, Jacob Keller <jacob.keller@gmail.com> wrote:
>> On Thu, Oct 1, 2015 at 9:43 AM, Robert Dailey <rcdailey.lists@gmail.com> wrote:
>>> For convenient pushing of current branch, git supports this syntax:
>>>
>>> $ git push origin HEAD
>>>
>>> This will push your current branch up. However, is there such a
>>> shortcut for *deleting* the branch? The only goal here is to avoid
>>> having to type the branch name in the push command. Normally I rely on
>>> tab completion but we have tons of branches, all which start with some
>>> prefix mixed with numbers, so it becomes cumbersome to rely on tab
>>> completion. Ideally I'd like to be able to do:
>>>
>>> $ git push --delete origin HEAD
>>> $ git push origin :HEAD
>>>
>>> Is there a syntax like this available?
>>
>> You can do
>>
>> git push origin:<branchname>
>>
>> but I don't believe HEAD is supported. It might be valuable to extend
>> push to have a --delete option which would maybe be useful for those
>> who didn't learn the full refspec syntax.
>
> Push already has a --delete option.
>

I could see adding an option for --delete-upstream that would use the
upstream remote and ref of the current branch (if they exist).
External to git you could script this from the config (completely
untested):

    if branch=$(git symbolic-ref --short HEAD); then
        if remote=$(git config branch.$branch.remote); then
            if remote_ref=$(git config branch.$branch.merge); then
                git push $remote --delete $remote_ref
            fi
        fi
    fi

>> I don't think git push origin :HEAD makes too much sense, since that's
>> on the remote side of a refspec, and you want it interpreted
>> locally... I suppose it makes sense somewhat, but other refspecs with
>> HEAD on the remote side of the refspec don't really make sense, where
>> as HEAD always makes sense on the local side of the refspec.
>
> HEAD makes sense on the remote side if you think of it like an alias:
>
> HEAD -> branch-name -> SHA1
>
> HEAD simply points to branch-name. It makes sense for git to assume
> that we should never do anything with real HEAD ref on the remote
> side, and instead treat it as a substitution for the remote name. My
> assumption may not be correct, but at the very least it should be a
> niche case.
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2015-10-02 13:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-01 16:43 Convenient shortcut to push delete current branch? Robert Dailey
2015-10-01 18:22 ` Jacob Keller
2015-10-01 18:37   ` Robert Dailey
2015-10-02 13:33     ` Mike Rappazzo

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 NNTP newsgroup(s).