-
Notifications
You must be signed in to change notification settings - Fork 6
Removing a Commit From a GitHub Repository
Editing the git history is bad practice in version control and should only be done in the case of a security issue.
Furthermore, please make sure that the author of the commit removes the file from their version of the branch, otherwise the same issue will occur.
1.Type the following command into GitBash/Command prompt (optional: you can include the hash value of the commit if you want to reset a specific commit).
git reset –soft HEAD^
This will reset the repository to a previous state.
2.Use the following git command to show that the repository has been returned to a previous state.
git commit -m “Reverting to the state of the project at <commit/commit hash>”
Edit <commit/commit hash> to state the specific commit/commit hash you are reverting to
3.Type the following git command into GitBash/Command prompt.
git push origin <name_of_branch> --force
4.Check the GitHub page here, finding the relevant repository/branch, to ensure the commit was removed from the commit history.
5.Ensure the author of the commit also follows this step-by-step guide to remove/modify the commit in their clone of the repository.
📧 Email us at [email protected] 🐦Find NHS Digital on Twitter 📘Check out the documentation for Codon