Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reset "local" git repository?

Tags:

git

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?

like image 521
Wosh Avatar asked Aug 06 '13 11:08

Wosh


People also ask

Is git reset local?

To review, git reset is a powerful command that is used to undo local changes to the state of a Git repo. Git reset operates on "The Three Trees of Git". These trees are the Commit History ( HEAD ), the Staging Index, and the Working Directory.

Will git reset delete local files?

Running git reset will typically delete files and commits. And without those, you don't have a project! This is why it's critical to plan ahead when using it, so you don't end up deleting elements that are critical for your project.


3 Answers

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.

like image 73
Morgan Avatar answered Sep 22 '22 02:09

Morgan


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

like image 36
lukassteiner Avatar answered Sep 20 '22 02:09

lukassteiner


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?

like image 2
Simson Avatar answered Sep 23 '22 02:09

Simson