-- Remove the history from | |
rm -rf .git | |
-- recreate the repos from the current content only | |
git init | |
git add . | |
git commit -m "Initial commit" | |
-- push to the github remote repos ensuring you overwrite history | |
git remote add origin git@github.com:<YOUR ACCOUNT>/<YOUR REPOS>.git | |
git push -u --force origin master |
This comment has been minimized.
This comment has been minimized.
Really helpful, saved my day |
This comment has been minimized.
This comment has been minimized.
thanks! |
This comment has been minimized.
This comment has been minimized.
Im afraid you can still reference specific "deleted" commits by hash, eventough they don't appear in history |
This comment has been minimized.
This comment has been minimized.
This might be problematic with repositories with git submodules.
|
This comment has been minimized.
This comment has been minimized.
This saved my day .. an is working "nearly" automatic. |
This comment has been minimized.
This comment has been minimized.
Warning : this does not delete pull request history (discussion, file changes). If you do this in order to delete sensitive data, you should better delete the github repo (along with all its pull request history etc..) and recreate a new one from scratch. |
This comment has been minimized.
This comment has been minimized.
Thanks it was very useful |
This comment has been minimized.
This comment has been minimized.
Above didn't work but the following worked with more attributes during the push.
|
This comment has been minimized.
This comment has been minimized.
Perfect !!! Just a small comment : |
This comment has been minimized.
This comment has been minimized.
Thanks, man! |
This comment has been minimized.
This comment has been minimized.
Great help, thanks. |
This comment has been minimized.
This comment has been minimized.
Thank you! |
This comment has been minimized.
This comment has been minimized.
Great help! Thank you |
This comment has been minimized.
This comment has been minimized.
It works perfectly ! Thank you ! |
This comment has been minimized.
This comment has been minimized.
Thanks! |
This comment has been minimized.
This comment has been minimized.
This did work for me, but initially I ran into problems after the two last lines (with my account and repo name, of course):
After running the last command, which failed, I started to get error messages for every command I used. I was not allowed to push. For example:
In my case, the solution was to follow this guide to use HTTPS instead of SSH: |
This comment has been minimized.
This comment has been minimized.
@heshanik, the |
This comment has been minimized.
This comment has been minimized.
that was a great help, many thanks |
This comment has been minimized.
This comment has been minimized.
awesome! thanks for share it |
This comment has been minimized.
This comment has been minimized.
Wonderful ! it worked |
This comment has been minimized.
This comment has been minimized.
Thank you! This one works well! |
This comment has been minimized.
This comment has been minimized.
I believe you need to delete and recreate the Github remote repo to completely remove the logs. See for example Recovering a commit from Githubs reflog. Using the Github API described there, you access commits that are stored on Github don't appear in the normal commit history on Github. With this method, you don't know have to know the SHA of a commit you are looking for. Also, if the project in question is public, it appears the API calls to review the history are also public. |
This comment has been minimized.
This comment has been minimized.
Thanks Heshanlk this worked for me, after adding git remote rm origin before the line git remote add origin [repro address] 'cause I was receiving: |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
Worked great, useful! |
This comment has been minimized.
This comment has been minimized.
for a |
This comment has been minimized.
This comment has been minimized.
If you want an empty repom then pass the
or else you'll get the following message:
|
This comment has been minimized.
This comment has been minimized.
This worked for me. Thanks. |
This comment has been minimized.
This comment has been minimized.
Awesome. This worked for me. Thank you. |
This comment has been minimized.
This comment has been minimized.
nice! |
This comment has been minimized.
This comment has been minimized.
Thanks a ton, really appreciate this! |
This comment has been minimized.
This comment has been minimized.
Does clearing the history in this way clear the contributions as well (i.e., reset everyone to 0/zero contributions on the Contributors page)? |
This comment has been minimized.
This comment has been minimized.
Awesome thank you! I did a new |
This comment has been minimized.
This comment has been minimized.
Thank you!!! |
This comment has been minimized.
This comment has been minimized.
Thank you. I was badly needing it! |
This comment has been minimized.
This comment has been minimized.
Saved my day!!! thank you! |
This comment has been minimized.
This comment has been minimized.
This helped so much!!!!!!!! |
This comment has been minimized.
This comment has been minimized.
so easy, thank you |
This comment has been minimized.
This comment has been minimized.
THANK YOU , I had an issue with lfs not removing the big files correctly, this fixed it right up |
This comment has been minimized.
This comment has been minimized.
thank you so much |
This comment has been minimized.
This comment has been minimized.
Very useful. Thank you. |
This comment has been minimized.
This comment has been minimized.
It helped me. Thanks! |
This comment has been minimized.
This comment has been minimized.
Thanks. I used Gatsby starter pack with bunch of commits made before I cloned it and this worked perfectly. |
This comment has been minimized.
This comment has been minimized.
Thank you! |
This comment has been minimized.
This comment has been minimized.
Thank you :D |
This comment has been minimized.
This comment has been minimized.
Great. |
This comment has been minimized.
This comment has been minimized.
thanks! |
This comment has been minimized.
This comment has been minimized.
Many kudos to you @stephenhardy Thanks :) |
This comment has been minimized.
This comment has been minimized.
You are a genius! |
This comment has been minimized.
This comment has been minimized.
Thank you, that helped |
This comment has been minimized.
This comment has been minimized.
Thanks a lot! works perfectly |
This comment has been minimized.
This comment has been minimized.
works like a charm, thank you! |
This comment has been minimized.
This comment has been minimized.
really useful, thanks!! |
This comment has been minimized.
This comment has been minimized.
check my gitclean bash script |
This comment has been minimized.
This comment has been minimized.
Exactly, what I needed. Thanks ( Its bad YADA YADA, but when testing, things happen.) |
This comment has been minimized.
This comment has been minimized.
very helpful thanks! |
This comment has been minimized.
This comment has been minimized.
Thank you! Perfect! |
This comment has been minimized.
This comment has been minimized.
thanks! |
This comment has been minimized.
This comment has been minimized.
thanks! |
This comment has been minimized.
This comment has been minimized.
I LOVE YOUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUu!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
This comment has been minimized.
This comment has been minimized.
I WORKED LIKE A DREAM!!!!!!!!!!!!!!! |
This comment has been minimized.
This comment has been minimized.
very helpful! thank you! |
This comment has been minimized.
This comment has been minimized.
this just came in handy. will fork! |
This comment has been minimized.
This comment has been minimized.
I am not very experienced with git and am now having all kinds of problems with every local repository command I try after trying to delete the history on a repo that I had published a personal API key in. Some common errors I am encountering. "git pull "git push "fatal: refusing to merge unrelated histories" Could someone guide me through some solutions? Sorry if this is an easy fix, I have tried many different fixes on numerous forums to no avail. Any help would be greatly appreciated. |
This comment has been minimized.
This comment has been minimized.
Nice summary ! Thanks |
This comment has been minimized.
This comment has been minimized.
This is excellent. Thank you so much. Such a time saver as it allows a total break from the original master. |
This comment has been minimized.
This comment has been minimized.
Great script! Thanks for sharing!, I was looking for this for a while. /usr/bin/git-clearHistory
|
This comment has been minimized.
This comment has been minimized.
Just what I needed; thank you |
This comment has been minimized.
This comment has been minimized.
Works 100% thank you |
This comment has been minimized.
This comment has been minimized.
Under DOS, use: rd /q /s .git |
This comment has been minimized.
This comment has been minimized.
Thank you!!!!! |
This comment has been minimized.
This comment has been minimized.
Thank you!!! |
This comment has been minimized.
This comment has been minimized.
Thank you!! Much helpful and saved may day. |
This comment has been minimized.
This comment has been minimized.
Thank you very much. It saved me. :) |
This comment has been minimized.
This comment has been minimized.
helped me remove my weird commits |
This comment has been minimized.
This comment has been minimized.
@adeluccar thank you!! |
This comment has been minimized.
This comment has been minimized.
Very useful. Thank you. |
This comment has been minimized.
This comment has been minimized.
It's works. Thank you |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
I cannot thank you enough for this! Extremely useful and saved my day! |
This comment has been minimized.
This comment has been minimized.
I can now sleep at night, Thank you! |
This comment has been minimized.
This comment has been minimized.
thanks |
This comment has been minimized.
This comment has been minimized.
you could also use rebase or squash to clean up weird commitlogs |
This comment has been minimized.
This comment has been minimized.
tfile=$(mktemp /tmp/config.XXXXXXXXX) |
This comment has been minimized.
This comment has been minimized.
Thank you |
This comment has been minimized.
This comment has been minimized.
Thanks! |
This comment has been minimized.
thanks, very usefull