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

Revision ref '@{push}' not resolved as documented

From
Alexandre Garnier <zigarn@gmail.com>
Date
Apr 2, 2023, 15:16 UTC
Message-ID
<CAFFOgCUs9d6wJDf3p-+8UkzXRSymCgBctGt+rP+k0CzZPp2LJw@mail.gmail.com>
Hi!

I followed the example of ref '@{push}' in the documentation of 'rev-parse' (https://git-scm.com/docs/git-rev-parse#Documentation/git-rev-parse.txt-emltbranchnamegtpushemegemmasterpushemempushem) and it doesn't work as documented. Here is a way to reproduce:

# Setup $ git init --bare origin.git $ git clone --bare origin.git myfork.git $ git clone origin.git local $ cd local/ $ git commit --allow-empty -m init $ git push origin $ git remote add myfork ../myfork.git

# Check for $ git rev-parse --symbolic-full-name @{upstream} refs/remotes/origin/main $ git rev-parse --symbolic-full-name @{push} refs/remotes/origin/main

# Follow doc's example $ git config push.default current $ git config remote.pushdefault myfork $ git switch -c mybranch origin/main $ git rev-parse --symbolic-full-name @{upstream} refs/remotes/origin/main $ git rev-parse --symbolic-full-name @{push} # should be refs/remotes/myfork/mybranch @{push} fatal: ambiguous argument '@{push}': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git <command> [<revision>...] -- [<file>...]'

# Push is done with the expected remote, and only then the ref can be resolved
$ git push
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
To ../myfork.git
* [new branch] mybranch -> mybranch
$ git rev-parse --symbolic-full-name @{push}
refs/remotes/myfork/mybranch

So it means the branch has to exist in the remote to resolve '@{push}' as a symbolic ref? I think I remember that a few years ago the example was working as-is without the need to push.

If this is the expected behavior (not the best IMHO as it was a way to check where it is going to be pushed before doing it), documentation of the ref needs to be updated I think.

Regards,
-- 
Alex Garnier
Next: Felipe Contreras
Message 1 of 3 in “Revision ref '@{push}' not resolved as documented”
  1. Alexandre GarnierApr 2, 2023
  2. Felipe ContrerasApr 2, 2023
  3. Junio C HamanoApr 3, 2023

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.