Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove old aliases and email from ALL commits

I have just noticed that my computer name and personal email were used as alias and email instead of my GitHub username and email.

Is there a way to completely remove ALL commits as well as all the history from GitHub?

like image 597
Johny19 Avatar asked Jan 19 '26 05:01

Johny19


1 Answers

Yes, there is! See below.

However, in this case you might also be interested to just replace your name and email address on all the commits: https://help.github.com/articles/changing-author-info/


From how to delete all commit history in github? and Make the current commit the only (initial) commit in a Git repository?

It depends on if you want to remove all configuration as well. If that's not an issue:

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

You can save your .git/config before, then restore it after.


Alternatively, leave the code in its current state but remove everything before (by making a new branch the new 'master' branch)

git checkout --orphan latest_branch
git add -A
git commit -am "commit message"
git branch -D master
git branch -m master
git push -f origin master
like image 200
BrechtDeMan Avatar answered Jan 21 '26 21:01

BrechtDeMan



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!