From: Jakub Narębski Date: Tue, 28 Jul 2015 10:01:04 GMT Subject: Re: git branch command is incompatible with bash Message-ID: <55B752E0.7020901@gmail.com> In-Reply-To: <55B72F09.3030000@kdbg.org> W dniu 2015-07-28 o 09:28, Johannes Sixt pisze: > Am 27.07.2015 um 23:49 schrieb Junio C Hamano: >> Johannes Sixt 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 > 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 [...] -- [...]' 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. > $ 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