never_had_a_name
never_had_a_name

Reputation: 93286

Empty all previous commits in Git?

I have a Git repository that I want to remove all previous commits from.

Cause I tested to commit junk files, now I want to "start over" with the repository.

Is this possible?

Upvotes: 3

Views: 96

Answers (2)

David Z
David Z

Reputation: 131730

Why not just delete the folder that contains the repository and create a new one?

If you want to save the latest versions of the files, you can just delete the directory .git within the top-level directory of the repository.

If you want to save some other version of the files, check out that version first, then delete .git.

Upvotes: 2

signine
signine

Reputation: 3123

Just delete the .git directory and 'git init' again to begin anew.

If you had done any configuration in the repo, you can always make a backup of the .git/config before removing the .git.

Upvotes: 4

Related Questions