Article

Remove Pushed Commits from GitHub Repository

AOAnonymous One· Feb 7, 20231 min read
  • #GitHub
  • #Git

Remove Pushed Commits from GitHub Repository

Remove pushed commits from your GitHub repository by using git.

Optional: Backup your repository just in case

cp ../GitHub-Repository ../GitHub-Repository-Backup

Choose the last commit you would like to keep

git reset --hard 'git-hash-code'

Optional: Remove files not under version control

git clean -f -d

Push the last commit you would like to keep to GitHub

git push -f

Check out your GitHub repository by visiting https://github.com/<github-username>/<repository-name> to checkout the changes.

0 Comments

Sign in to join the conversation.

Search

Jump to a page, story or project