Re: How to use @{-1} with push?

3 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: How to use @{-1} with push?

From: Junio C Hamano <hidden>
Date: 2016-06-15 23:08:58

Robert Dailey [off-list ref] writes:
Both should refer to the last branch, but I know that these can't be
used verbatim in a push command because it doesn't read it as a branch
name normally like `git checkout` would.
You can ask rev-parse to give you --symbolic-full-name, error out if
it is empty (i.e. detached HEAD), and otherwise use the result, no?

    $ git checkout next
    $ git checkout master
    $ git rev-parse --symbolic-full-name @{-1}
    refs/heads/master
    $ git checkout HEAD^0
    $ git checkout master
    $ git rev-parse --symbolic-full-name @{-1}
    $ exit

And

    $ git push origin :refs/heads/master

would be the fully-spelled out way to remove that branch.

Re: How to use @{-1} with push?

From: Robert Dailey <hidden>
Date: 2016-06-15 23:08:58

On Fri, Mar 25, 2016 at 12:45 PM, Junio C Hamano [off-list ref] wrote:
You can ask rev-parse to give you --symbolic-full-name, error out if
it is empty (i.e. detached HEAD), and otherwise use the result, no?

    $ git checkout next
    $ git checkout master
    $ git rev-parse --symbolic-full-name @{-1}
    refs/heads/master
    $ git checkout HEAD^0
    $ git checkout master
    $ git rev-parse --symbolic-full-name @{-1}
    $ exit

And

    $ git push origin :refs/heads/master

would be the fully-spelled out way to remove that branch.
Thanks Junio, I figured there was a command to do that. I tried to do
this using '-' shorthand, but that didn't work. I guess because that's
not really a revision, but a special function of git checkout only.

Re: How to use @{-1} with push?

From: Robert Dailey <hidden>
Date: 2016-06-15 23:08:58

On Fri, Mar 25, 2016 at 1:02 PM, Robert Dailey [off-list ref] wrote:
On Fri, Mar 25, 2016 at 12:45 PM, Junio C Hamano [off-list ref] wrote:
quoted
You can ask rev-parse to give you --symbolic-full-name, error out if
it is empty (i.e. detached HEAD), and otherwise use the result, no?

    $ git checkout next
    $ git checkout master
    $ git rev-parse --symbolic-full-name @{-1}
    refs/heads/master
    $ git checkout HEAD^0
    $ git checkout master
    $ git rev-parse --symbolic-full-name @{-1}
    $ exit

And

    $ git push origin :refs/heads/master

would be the fully-spelled out way to remove that branch.
Thanks Junio, I figured there was a command to do that. I tried to do
this using '-' shorthand, but that didn't work. I guess because that's
not really a revision, but a special function of git checkout only.
So the push works with the fully-qualified ref, but not git branch:

$ git rev-parse --symbolic-full-name foo
refs/heads/foo

$ git branch -d refs/heads/foo
error: branch 'refs/heads/foo' not found.

Any reason for this? I'm using git 2.7.4 on windows
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help