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

git remote rm considered harmful?

From
Jay Soffian <jaysoffian@gmail.com>
Date
Feb 1, 2009, 14:52 UTC
Message-ID
<76718490902010652w7a332550w5e0658a390c7dea9@mail.gmail.com>

Yesterday I was not paying attention to a repository I was in when I used git remote to make a mirror:

$ git remote add --mirror bar git://foo/bar
I realized my mistake and removed the mirror:
$ git remote rm bar
Poof. All of my local branches and their reflogs were gone. Reproduce with:

# Setup a repository mkdir foo && cd foo && git init echo foo > foo && git add foo && git commit -m foo

# Make some branches for demonstration purposes git co -b branch1 git co -b branch2 git co -b branch3 git co master find .git/refs .git/logs .git/refs .git/refs/heads .git/refs/heads/branch1 .git/refs/heads/branch2 .git/refs/heads/branch3 .git/refs/heads/master .git/refs/tags .git/logs .git/logs/HEAD .git/logs/refs .git/logs/refs/heads .git/logs/refs/heads/branch1 .git/logs/refs/heads/branch2 .git/logs/refs/heads/branch3 .git/logs/refs/heads/master

# Setup a remote git remote add --mirror bar git://foo/bar

# Oops, didn't mean to do that, remove the repo git remote rm bar # poof! find .git/refs .git/logs .git/refs .git/refs/heads .git/refs/tags .git/logs .git/logs/HEAD .git/logs/refs .git/logs/refs/heads

I just realized that at least the HEAD log is still there. I missed that originally since:

git reflog fatal: bad default revision 'HEAD'

(Separate issue, but shouldn't "git reflog" work even if .git/HEAD is invalid?)

Anyway, it would seem to me it should be harder to remove local refs. This one was somewhat painful to recover from. Not sure what better behavior would be: should it be harder to do "remote add --mirror" on a repository with content, should "remote rm" on mirrored repository require a --force switch with a stern warning first, or...?

Thoughts?
j.
Next: Jay Soffian
Message 1 of 17 in “git remote rm considered harmful?”
  1. Jay SoffianFeb 1, 2009
  2. builtin-remote: make rm operation safer in mirrored repositoryJay Soffian, Feb 1, 2009
  3. Jeff KingFeb 2, 2009
  4. Jay SoffianFeb 2, 2009
  5. builtin-remote: make rm operation safer in mirrored repositoryJay Soffian, Feb 2, 2009
  6. Jeff KingFeb 3, 2009
  7. Junio C HamanoFeb 3, 2009
  8. Jay SoffianFeb 3, 2009
  9. Johannes SchindelinFeb 3, 2009
  10. 1/2 builtin-remote: make rm() use properly named variable to hold return valueJay Soffian, Feb 3, 2009
  11. 2/2 builtin-remote: make rm operation safer in mirrored repositoryJay Soffian, Feb 3, 2009
  12. Jeff KingFeb 4, 2009
  13. Jay SoffianFeb 4, 2009
  14. builtin-remote: make rm operation safer in mirrored repositoryJay Soffian, Feb 4, 2009
  15. Jeff KingFeb 4, 2009
  16. Jeff KingFeb 4, 2009
  17. Jeff KingFeb 4, 2009

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.