Last Updated: February 25, 2016
·
541
· erivello

Reset git history

rm -rf .git
git init
git add .
git commit -m "Initial commit"
git remote add origin <git-uri>
git push -u --force origin master

4 Responses
Add your response

Why the hell anybody should do that?

over 1 year ago ·

We have a gitlab server and we use a git repo to version images, css and javascripts.
The hard disk is not to big, so we have to remove history sometimes.
We do this only for this git repo, don't worry ;)

over 1 year ago ·

@erivello: Then why not simply use git gc --prune=now? Also using Git to version binary files is bad idea. Maybe it will be fixed in 2.0, but I bet that it won't.

over 1 year ago ·

Very interesting this 'git gc' command, tnks.

over 1 year ago ·