Delete Github commit history

后端 未结 4 1804
天涯浪人
天涯浪人 2021-01-30 03:39

Is there anyway for me to delete my github commit history? I don\'t want to lose all my commits, just the last 10 or so that were pushed to github. I can\'t seem to figure out h

4条回答
  •  别那么骄傲
    2021-01-30 04:07

    I had uploaded all of my files to my first github project, including some settings files with secret keys. I had to go back and remove all the versions that were included before I added my .gitignore file, and deleted all settings files from my project's cache.

    How I did this:

    gedit ./.git/logs/HEAD

    Find the 40-character SHA hash of the 'new root' you wish to delete everything prior to. Copy it to the clipboard and close it. (You may or may not use gedit, a default text editor for linux).

    $> gedit ./.git/info/grafts

    Paste the SHA here. Go to your project's directory.

    $> cd ../..

    $> git filter-branch

    Force the push to the master, otherwise it will block your attempt to erase your history.

    $> git push --force -u origin master

    Delete your grafts file.

    $> rm ./.git/info/grafts

    NEVERMIND

    Well, my answer is only half the battle. My public activity RSS feed still has links to all the diffs that detail the very information I wanted to remove. Apparently, there is no way to delete this, but you should probably read Change your Password, and update any sensitive data you may have accidentally uploaded.

提交回复
热议问题