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

`git remote rename` does not work when `refs/remotes/server/HEAD` is unborn (when right after `git remote add -m`)

From
Han Jiang <jhcarl0814@gmail.com>
Date
Jul 24, 2025, 09:59 UTC
Message-ID
<CANrWfmQWa=RJnm7d3C7ogRX6Tth2eeuGwvwrNmzS2gr+eP0OpA@mail.gmail.com>
What did you do before the bug happened? (Steps to reproduce your issue)

mkdir --parents -- './server' './client'; git -C './server' init --bare './repo.git' branch_default_name="$(git -C './server/repo.git' branch --show-current)"; echo "$branch_default_name" git --git-dir='./server/repo.git' --work-tree='.' commit --message="$((++number))" --allow-empty git -C './client' init './repo' cd './client/repo' git remote add -m "$branch_default_name" server 'file://'"$(realpath '../../server/repo.git')" git remote --verbose git config list --local --show-scope --show-origin git symbolic-ref 'refs/remotes/server/HEAD' git remote rename server server2 git config list --local --show-scope --show-origin git symbolic-ref 'refs/remotes/server2/HEAD' git symbolic-ref 'refs/remotes/server/HEAD'

What did you expect to happen? (Expected behavior)

`git symbolic-ref 'refs/remotes/server/HEAD'` outputs "refs/remotes/server/master"; `git symbolic-ref 'refs/remotes/server2/HEAD'` outputs "refs/remotes/server2/master".

What happened instead? (Actual behavior)

`git symbolic-ref 'refs/remotes/server/HEAD'` outputs "refs/remotes/server/master"; `git symbolic-ref 'refs/remotes/server2/HEAD'` outputs "fatal: ref refs/remotes/server2/HEAD is not a symbolic ref". `git symbolic-ref 'refs/remotes/server/HEAD'` outputs "refs/remotes/server/master".

What's different between what you expected and what actually happened?
Anything else you want to add:

Please review the rest of the bug report below. You can delete any lines you don't wish to share.

[System Info]
git version:
git version 2.50.1.windows.1
cpu: x86_64
built from commit: 4d32d83913170b86f9753fca10e75cdb2223d1cc
sizeof-long: 4
sizeof-size_t: 8
shell-path: D:/git-sdk-64/usr/bin/sh
feature: fsmonitor--daemon
libcurl: 8.14.1
OpenSSL: OpenSSL 3.2.4 11 Feb 2025
zlib: 1.3.1
SHA-1: SHA1_DC
SHA-256: SHA256_BLK
uname: Windows 10.0 26100
compiler info: gnuc: 15.1
libc info: no libc information available
$SHELL (typically, interactive shell): C:\Program Files\Git\usr\bin\bash.exe

[Enabled Hooks] not run from a git repository - no hooks to show

Next: Jeff King
Message 1 of 10 in “`git remote rename` does not work when `refs/remotes/server/HEAD` is unborn (when right after `git remote add -m`)”
  1. Han JiangJul 24, 2025
  2. Jeff KingJul 24, 2025
  3. Patrick SteinhardtJul 24, 2025
  4. Patrick SteinhardtJul 24, 2025
  5. Junio C HamanoJul 24, 2025
  6. Patrick SteinhardtJul 25, 2025
  7. Jeff KingJul 25, 2025
  8. Jeff KingJul 25, 2025
  9. Patrick SteinhardtJul 28, 2025
  10. Patrick SteinhardtJul 28, 2025

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.