Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove working tree from a Git repository

Tags:

git

I'd like to convert my Git repository to a bare one. I distinctly remember something like git remove-tree that did the job previously but I can't find it on 1.7. Could you help me out?


Thanks guys, that did it with the moving of repo to a different place and then setting the bare=true option.

I must say my memory has failed me this time. The trick with removing working copy that I did previously was with Bazaar :)

Anyways - thanks for the answers.

like image 572
Matthias Hryniszak Avatar asked Sep 11 '11 19:09

Matthias Hryniszak


People also ask

How do I delete a working tree?

prune Prune working tree information in $GIT_DIR/worktrees. remove Remove a working tree. Only clean working trees (no untracked files and no modification in tracked files) can be removed. Unclean working trees or ones with submodules can be removed with --force.

What is the working tree in git?

The working tree is the set of all files and folders a developer can add, edit, rename and delete during application development. The status command can provide insight into how the Git working tree behaves. More colloquially, developers often refer to the Git working tree as the workspace or the working directory.


2 Answers

Cloning your git repository, as suggested in Skydreamer's answer, may be fine for what you want, but it would lose remote-tracking branches, settings in .git/config, etc. An alternative is to just reuse the .git directory as a bare repository, e.g. by doing:

cd my-repo
mv .git ../my-repo.git
cd ../my-repo.git
git config core.bare true

... which will leave my-repo with just your working tree, and my-repo.git as a bare version of the same repository.

like image 174
Mark Longair Avatar answered Sep 23 '22 03:09

Mark Longair


git clone --bare old_directory new_directory

like image 39
Cydonia7 Avatar answered Sep 23 '22 03:09

Cydonia7