git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* git remote rm considered harmful?
@ 2009-02-01 14:52 Jay Soffian
  2009-02-01 15:48 ` [PATCH] builtin-remote: make rm operation safer in mirrored repository Jay Soffian
  0 siblings, 1 reply; 17+ messages in thread
From: Jay Soffian @ 2009-02-01 14:52 UTC (permalink / raw)
  To: Git Mailing List

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.

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2009-02-04 16:19 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-01 14:52 git remote rm considered harmful? Jay Soffian
2009-02-01 15:48 ` [PATCH] builtin-remote: make rm operation safer in mirrored repository Jay Soffian
2009-02-02 13:29   ` Jeff King
2009-02-02 13:36     ` Jay Soffian
2009-02-02 18:40       ` Jay Soffian
2009-02-03  7:24         ` Jeff King
2009-02-03  7:54           ` Junio C Hamano
2009-02-03 14:38             ` Jay Soffian
2009-02-03 14:53               ` Johannes Schindelin
2009-02-03 17:51               ` [PATCH 1/2] builtin-remote: make rm() use properly named variable to hold return value Jay Soffian
2009-02-04 15:34                 ` Jeff King
2009-02-03 17:51               ` [PATCH 2/2] builtin-remote: make rm operation safer in mirrored repository Jay Soffian
2009-02-04 15:42                 ` Jeff King
2009-02-04 15:56                   ` Jay Soffian
2009-02-04 16:06                     ` [PATCH] " Jay Soffian
2009-02-04 16:18                       ` Jeff King
2009-02-04 16:16                     ` [PATCH 2/2] " Jeff King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).