git/list[1] front-page[2] threads[3] people[4] search[5] about
 

How to use @{-1} with push?

From
RDRobert Dailey <rcdailey.lists@gmail.com>
Date
Mar 25, 2016, 14:40 UTC
Message-ID
<CAHd499AM-OzqiB1hOF=0BTesFxrxNj=+jr1wH6vpQXfgoXd8Ug@mail.gmail.com>
I have an alias that I'm working on to do a push and delete of a topic branch:
    # Push HEAD, delete branch local & remote
    #
    # $1 = remote name
    # $2 = branch name
    pushdel = "!f() { : git push ; git push \"$1\" HEAD \":$2\" && git
branch -d \"$2\" ; }; f"
I use it after I merge a topic branch, like so:
$ git pushdel origin my-topic-branch
What would be nice is if I could do one of the two:

$ git pushdel origin - $ git pushdel origin @{-1}

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. I'm not sure why, as I do not have knowledge of the underlying mechanics of these commands.

Is there a way I can use these "relative" branch shorthands in my push command? If not directly, perhaps there is a way I can update my alias to do an intermediate translation?

Thanks in advance.
Next: Junio C Hamano
Message 1 of 6 in “How to use @{-1} with push?”
  1. Robert DaileyMar 25, 2016
  2. Junio C HamanoMar 25, 2016
  3. Robert DaileyMar 25, 2016
  4. Robert DaileyMar 25, 2016
  5. Junio C HamanoMar 25, 2016
  6. Robert DaileyMar 28, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.