Reset git bare repo

After playing around with GIT, it is time to get serious. My intent is to revert my bare repo to the state its was before i started playing around with it. I kinda like git, but this thing has a million (actually a few dozens) set of commands some of them make sense others not really.

How do i reset my bare repo to its original state?

First check the log so you can grab the SHA1 of the original commit

git log

Note that you cannot do a “git reset sde4545e4” on a bare repo you will like get this error:
“fatal: mixed reset is not allowed in a bare repository”.

Second run the following command

git update-ref HEAD sde4545e4

Now there are still left over objects on the system. If you check the ./git/objects folder, you will see a whole bunch of directories there. You will need to get rid of them.

Third get rid of unwanted objects

git gc
git prune
Let's share thisShare on Facebook
Tweet about this on Twitter
Share on LinkedIn