how to restart a git repository

The best strategy for handling this would be to use the git archive command. This will export an unversioned version of your tree in a tar archive. Select your branch that you'd like to export and run the following inside your repository:

git archive master | tar -x -C ~/target/directory

You can then cleanly delete your repository folder and then extract your archive to start anew. Finally, you can create a new repository in your extracted folder as follows:

git init

I do this all the time. got into the working directory and if your on linux or mac do a

rm -rf .git

then I do a

git init
git add .
git commit -m "first time load"

that's all you need


Can backup – then delete the .git folder – and start fresh?

Yes. This is all there is to it.

Some really exotic set-ups might have the .git folder outside of the working directory; but otherwise the .git folder contains all the information there is wrt git. If you remove that, you remove all history, git-metadata and such.

If you had remotes, the link to them is lost, as that is stored in the same .git folder. The remote itself, on say your Gitlab server, is obviously not gone. So if you re-add that same remote on your clean environment it will cause history to re-appear, which might cause merge conflicts.

Edit: for those who might not have read the entire question: warning: this will remove all your git history.