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

Re: git branch command is incompatible with bash

From
Jakub Narębski <jnareb@gmail.com>
Date
Jul 28, 2015, 10:01 UTC
Message-ID
<55B752E0.7020901@gmail.com>
In-Reply-To
<55B72F09.3030000@kdbg.org>
W dniu 2015-07-28 o 09:28, Johannes Sixt pisze:
Show 15 quoted lines
> Am 27.07.2015 um 23:49 schrieb Junio C Hamano:
>> Johannes Sixt <j6t@kdbg.org> writes:
>>
>>> Try
>>>
>>>    branchName=$(git rev-parse --abbrev-ref HEAD)
>>
>> Hmm, interesting.
>>
>>      $ git checkout --orphan notyet
>>      $ git rev-parse --abbrev-ref HEAD
>>      $ git symbolic-ref --short HEAD
>>
>
> Please don't scare newcomers with these corner cases ;-)
:-P
Yet another corner case:
   $ git checkout origin/master # or v1.0.0
   $ git rev-parse --abbrev-ref HEAD
   $ git symbolic-ref --short HEAD
Show 8 quoted lines
> I see this:
>
> $ git rev-parse --abbrev-ref HEAD
> HEAD
> fatal: ambiguous argument 'HEAD': unknown revision or path not in the
> working tree.
> Use '--' to separate paths from revisions, like this:
> 'git <command> [<revision>...] -- [<file>...]'

Errr... this error message is errorneous (well, at least somewhat misleading). Git should know that HEAD is not a path, and that --abbrev-ref doe not need no revision.

Show 5 quoted lines
> $ git symbolic-ref --short HEAD
> notyet
>
> Are you trying to say that the result of 'rev-parse --abbrev-ref HEAD'
> is suboptimal and that of 'symbolic-ref --short HEAD' is OK?
-- 
Jakub Narębski
Previous: Johannes SixtNext: Junio C Hamano
Message 5 of 9 in “git branch command is incompatible with bash”
  1. Anatol RudolphJul 27, 2015
  2. Johannes SixtJul 27, 2015
  3. Junio C HamanoJul 27, 2015
  4. Johannes SixtJul 28, 2015
  5. Jakub NarębskiJul 28, 2015
  6. Junio C HamanoJul 28, 2015
  7. Jeff KingJul 28, 2015
  8. Johannes SixtJul 28, 2015
  9. Scott SchmitJul 29, 2015

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.