git-filter-repo icon indicating copy to clipboard operation
git-filter-repo copied to clipboard

Git remote is not being deleted by git-filter-repo when cloned with --mirror

Open beyerjsb opened this issue 3 years ago • 6 comments

Thanks for this awesome tool. I found a "small" issue which may be severe.

Edit: new description since I found out what specifically triggers the issue. Old text below.

When the git repo is cloned with --mirror, git filter-repo does not delete the remote origin address. When the git repo is cloned without --mirror, git filter-repo deletes the remote.

--- old text follows --- The user manual states:

git-filter-repo deletes the "origin" remote to help avoid people accidentally repushing to the same repository, so you’ll need to remind git what origin’s url was. You’ll have to look up the command for that.

However, it doesn't. I've tried the tool, and the remote is still active. Is the user manual wrong, so that it needs another command line flag to do it, or is the functionality broken?

beyerjsb avatar Feb 23 '22 07:02 beyerjsb

Can you report the output of git remote -v after running, and the git-filter-repo command line you used?

newren avatar Feb 23 '22 08:02 newren

Can you report the output of git remote -v after running, and the git-filter-repo command line you used?

PS > git remote -v
origin  <repourl> (fetch)
origin  <repourl> (push)

I'm experimenting with a quite large repo rewrite which uses different filter-repo commands.

git filter-repo --tag-rename
git filter-repo --replace-message
git filter-repo --invert-paths
git filter-repo --path-rename
git filter-repo --replace-refs
git filter-repo --mailmap

beyerjsb avatar Feb 23 '22 08:02 beyerjsb

Are you using --partial, --refs, --source, or --target by chance?

newren avatar Feb 23 '22 08:02 newren

No, I'm not using --partial, I'm not afraid of a complete rewrite (it will be anyway), and I'm also replacing in-situ, not using --source or --target. Also I'm always going through the whole repo, so no --ref.

If that matters: the original repo is cloned using --reference and then issuing git repack -a -d and removing the alternate file before the use of git filter-repo. But I think this should not matter.

It's a --mirror clone, if this matters?

If you need any more information, I'll be happy to provide. Unfortunately it's a private repo I can't share.

beyerjsb avatar Feb 23 '22 08:02 beyerjsb

I did some testing, and the culprit is --mirror when cloning. When I clone "normally", gilter filter-repo removes the remote. I'll update the title and the text accordingly.

beyerjsb avatar Feb 23 '22 11:02 beyerjsb

Ah, yeah, good catch. It bases on whether there are refs/remotes/origin/* refs to rewrite, which there won't be for a mirror clone. Updating the docs would be good.

newren avatar May 28 '22 03:05 newren