Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can I empty a remote git repository?

Tags:

git

I created new remote git repository and already pushed something in there - first test push and then real code push from local. I want to start from scratch so I can creat few branches (master = ready to release code, test branch and branches for developers) and give them different permissions per user.

Can I empty the existing remote repository somehow? It's a remote git repository that sits on linux and developer and I run windows box.

like image 700
Radek Avatar asked Nov 08 '10 00:11

Radek


2 Answers

I don't think it is very useful, but you can restart the master branch (forgetting all history) by

rm .git/index .git/refs/heads/master
echo "Hello!" > README
git add README
git commit -m "Exterminate! Exterminate!"

and push to your remote repository. Usually I would just start over with an empty repository, add your remote repository and push from there.

Some explanation: The first line deletes the index (so your next commit won't contain any files) and the current pointer to the tip of the master branch (so your next commit won't be committed on top of any previous commit). In the second and third line, we add some content to our new repository and commit that content in the fourth line.

like image 87
Sven Marnach Avatar answered Sep 22 '22 23:09

Sven Marnach


If you want the repo gone, just take it away! Delete the whole containing directory, and recreate it as you see fit.

Yes, you could also make a new repo just on your end, and force push to the remote, and remotely delete all the refs, and then make sure git gc gets run on it... but that takes time and effort. Just wipe it out.

like image 25
Cascabel Avatar answered Sep 22 '22 23:09

Cascabel