1

I normally upload my files to Github repository through the web interface. I accidentally uploaded a file to Github repository recently and this file contains information which I don't want others to see. Now, this private info is permanently recorded in the commit history.

How can I delete this specific commit from Github?

EDIT: The commit history was created through the file upload website of github. It was not created using git.

user3848207
  • 3,737
  • 17
  • 59
  • 104
  • Does this answer your question? [Remove sensitive files and their commits from Git history](https://stackoverflow.com/questions/872565/remove-sensitive-files-and-their-commits-from-git-history) – user7247147 May 13 '20 at 06:46
  • @sasha-dev, no. The commit history was created through the file upload website of github. It was not created using git. – user3848207 May 13 '20 at 06:48
  • 1
    just clone the repository locally and run `git reset --hard ~` then force push you can't do it through the interface – user7247147 May 13 '20 at 07:06

1 Answers1

0

I will answer my own question. Credit goes to sasha-dev for his comment.

Here is what I did.

  • Use Github desktop to clone the github repostitory.
  • Launch command-line prompt. Go to the repository folder. Run the following command;

git reset --hard HEAD~1 # remove last commit

Or the goal is to remove a specific commit, find out the commit hash

git reset --hard <commit hash>~

Next step is to force push the locally made changes to the remote github repository. Run this command;

git push -f

Commits will be removed from github repository at this point.

user3848207
  • 3,737
  • 17
  • 59
  • 104