Wosh
Wosh

Reputation: 1625

How to reset "local" git repository?

I was trying to ignore some folders when pushing and ended up with only the .gitignore in the repository. Now want to "reset" my repository (by reset I mean to remove all the rules I applied and clean the commit area), so that I can add all my files and remove the folders I don't want after that. Any help?

Upvotes: 75

Views: 121077

Answers (3)

Morgan
Morgan

Reputation: 20514

You could just delete your .git folder and start again.

rm -rf .git
git init

This will leave the current .gitignore in place, which would still be followed by the new git repo. The .gitignore could be removed, or delete the contents so it is a blank file.

Upvotes: 164

Simson
Simson

Reputation: 3559

If you do not need a clean history just remove the files from the repository and commit your changes. If you would like to revert to an earlier commit there is a git reset command

git reset --hard HEAD^

Here is some more info How to undo last commit(s) in Git?

Upvotes: 0

lukassteiner
lukassteiner

Reputation: 847

If you want to create the repository again, then just remove the .git directory.

Upvotes: 12

Related Questions