2

When a repository is cloned by using simple git clone repo, the master branch is automatically checked out. If after this automatic checkout, I want to delete all files checked out and turn the clone in to a bare clone, how can I achieve this? Are there configurations within the .git folder that I can modify to accomplish this?

Side note: I know that specifying the --no-checkout or -n flag during clone prevents checkout of HEAD and keeps the repository bare. If I delete the files that are checked out, those files will be shown as deleted when running git status.

1

1 Answer 1

3

git clone --no-checkout doesn't give a bare repository, it just leaves the work tree and index empty. git status after such a clone will say that all files have been staged for deletion.

A bare repository is one with core.bare = true (and a bare repository made with git clone --bare will also not have any remote refs). You can do git config core.bare true to flip this bit. Then remove the work tree and index, and possibly rename the directory from repo/.git to repo.git.

Sign up to request clarification or add additional context in comments.

1 Comment

I did confuse bare and no-checkout. This is exactly what I was looking for.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.