Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git -- Rewrite entire history [duplicate]

Tags:

git

I want to do an explicitly bad thing. I have a project where I am the only developer and I want to put it on Github but it's littered with absolutely terrible commit message. I want to basically re-init the repo so that when I push it to the public repo it doesn't have my asinine comments.

I've considered just deleting the .git file(directory?) but that seems wrong, but of course what I am doing is also a terrible practice in and of itself so maybe that really is the bet route?

like image 875
Patrick Cauley Avatar asked Oct 16 '25 17:10

Patrick Cauley


1 Answers

An interactive rebasde would allow you to review each commit message and change the ones you want:

git rebase --root -i

Or, as suggested, you can simply create a new repo and, using the --work-tree option, add everything from your old repo:

git init newrepo
cd newrepo
git --work-tree=/path/to/old/repo add .
git commit -m "Import old repo"
git push -u origin master
like image 124
VonC Avatar answered Oct 18 '25 10:10

VonC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!