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

Using "-" for "previous branch" failing with rebase

From
TCTim Chase <git@tim.thechases.com>
Date
Mar 15, 2014, 20:29 UTC
Message-ID
<20140315152924.26c3294e@bigbox.christie.dr>

I recently learned that there are several places where git allows use of "-" to refer to the previous branch, e.g.

  git checkout -b dev
  # hack, hack
  git checkout master
  git merge -
  git checkout -
However, it doesn't seem to understand "-" in the context of a rebase:
  git checkout branch_a
  # hack
  git commit -a
  git checkout branch_b
  # hack
  git commit -a
  git rebase -         # I'd expect to rebase onto branch_a
but I get
  fatal: Needed a single revision
  invalid upstream -
Issuing
  git rebase branch_a

does exactly what I'd expect (as "git checkout -" puts me on "branch_a").

Is this just an interface inconsistency or is there a some technical reason this doesn't work (or, has it been addressed/fixed, and just not pulled into Debian Stable's 1.7.10.4 version of git)?

Thanks,
-tkc
Next: Junio C Hamano
Message 1 of 4 in “Using "-" for "previous branch" failing with rebase”
  1. Tim ChaseMar 15, 2014
  2. Junio C HamanoMar 17, 2014
  3. Tim ChaseMar 18, 2014
  4. Junio C HamanoMar 18, 2014

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.