How to reset "local" git repository?

Git

Git Problem Overview


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?

Git Solutions


Solution 1 - Git

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.

Solution 2 - Git

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

Solution 3 - Git

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 https://stackoverflow.com/questions/927358/how-to-undo-the-last-git-commit?rq=1

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionWoshView Question on Stackoverflow
Solution 1 - GitMorganView Answer on Stackoverflow
Solution 2 - GitlukassteinerView Answer on Stackoverflow
Solution 3 - GitSimsonView Answer on Stackoverflow