How can I delete a working copy created with git-new-workdir without using the original repo?

I am using the git-new-workdir script in the contrib section of the git codebase: to work on multiple branches of the same codebase at the same time. This is on windows using msysgit and the repo is a git svn repo, not a pure git. I have no problem making working copies using this command, saying:

git-new-workdir original-working-copy new-working-copy branch-name-to-checkout


But when I am no longer interested in the branch and I want to get rid of the working copy, the execution rm -rfR new-working-copy

also hoses with the original working copy.

The reverse order is obvious, given that git-new-workdir uses hard links to share the same .git relay between multiple working copies.

What is a good way to clean up working copies created this way that I no longer want on my machine?


source to share

2 answers

On normal UNIX systems, git-new-workdir

uses symbolic links to share everything with the original repo, so you can just rm -rf new-working-copy

delete the new workdir and you're good to go.

I have no idea what might change in msysgit which will change this.

It turns out, as noted in the comments, the problem is what rm

on Windows uses del

, which actually gets rewritten into symbolic links. Removing a symbolic link is required rmdir




As pointed out in the comments, here is the batch file I am using.

cd %1\.git
del HEAD
del config
rmdir hooks
del index
rmdir svn
rmdir refs
del packed-refs
rmdir objects
del remotes
del rr-cache
rmdir info
rmdir logs\refs
del logs\HEAD
rmdir logs
cd ..
rmdir .git
cd ..




All Articles