Identify the hash of the commit, using git log, then use git revert <commit> to create a new commit that removes these changes. In a way, git revert is the converse of git cherry-pick -- the latter applies the patch to a branch that's missing it, the former removes it from a branch that has it.

Answer from Andrew Aylett on Stack Overflow
Discussions

Git - Revert a change of a single file from a specific commit.
You probably want git revert B. However, if B introduced changes to other unrelated files, then that will also revert those. So to avoid that, use git revert -n so that it doesn't actually do the commit. Then do git reset to clear the index, and then git add File.txt and then commit. You'll still have the other unrelated changes in the other files in your working dir, so at that point you'd probably want to git reset --hard. More on reddit.com
🌐 r/learnprogramming
6
2
October 13, 2016
[Git] How to 'git reset' a remote branch?
On July 1st, a change to Reddit's API pricing will come into effect. Several developers of commercial third-party apps have announced that this change will compel them to shut down their apps. At least one accessibility-focused non-commercial third party app will continue to be available free of charge. If you want to express your strong disagreement with the API pricing change or with Reddit's response to the backlash, you may want to consider the following options: Limiting your involvement with Reddit, or Temporarily refraining from using Reddit Cancelling your subscription of Reddit Premium as a way to voice your protest. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
🌐 r/learnprogramming
13
5
February 12, 2024
Make submodule point to certain commit (not head)
Submodules do point to a specific commit, not a branch. That is actually the reason you're having trouble, the submodule is set to point at the commit set but the repository holding it, therefore your HEAD is detached from a branch If there's a branch on the commit you're on, you can just `git checkout ` and your HEAD should attach itself to the branch, allowing you to push the submodule, and then push the new commit pointer to the repository holding it More on reddit.com
🌐 r/git
4
2
July 26, 2024
Remove all changes merged from a specific branch
The git revert command is able to revert a merge, but you won't be able to merge those commits again. I guess it may work if you rebase the commits you are interested in on the feature branch or create a new feature branch and cherry-pick the commits. Reverting a merge commit declares that you will never want the tree changes brought in by the merge. As a result, later merges will only bring in tree changes introduced by commits that are not ancestors of the previously reverted merge. More on reddit.com
🌐 r/git
13
1
July 18, 2024
🌐
GitKraken
gitkraken.com › home › learn › problems & solutions › how to revert a git commit
Git Revert Commit | Solutions to Git Problems
February 5, 2024 - Now run git revert <commit ID>. This creates a new commit that negates the commit you specified.
🌐
Codefinity
codefinity.com › courses › v2 › 7533d91f-0a23-44a3-afc7-c84d5072e189 › b9a4a4e8-3d95-4d5d-bf29-f87c3fd673a4 › c3bcd665-926a-44bf-adf1-d1f97167d536
Learn Reverting a Specific Commit | Undoing Changes
To revert a specific commit, use the git revert command. This command creates a new commit that reverses the changes introduced by the specified commit.
Find elsewhere
🌐
Git Tower
git-tower.com › learn › git faq › how to undo, revert, or delete a git commit
How to Undo, Revert, or Delete a Git Commit | Learn Version Control with Git
If you only want to restore your whole project to a specific earlier state, read more about how to reset to a previous revision. What if you want to undo the effects of a commit that's not the most recent one — without touching any commits that came after it? That's what git revert is for.
Published   4 days ago
🌐
GitLab
docs.gitlab.com › topics › git › undo
Revert and undo changes | GitLab Docs
These tools are faster because they do not provide the same feature set as git filter-branch does, but focus on specific use cases. For more information about purging files from the repository history and GitLab storage, see reduce repository size. Undo your last commit and put everything back in the staging area: ... Edit a file. ... If a file was changed in a commit, and you want to change it back to how it was in the previous commit, but keep the commit history, you can use git revert.
🌐
TheServerSide
theserverside.com › tutorial › How-to-git-revert-a-commit-A-simple-undo-changes-example
How to revert a Git commit: A simple example | TheServerSide
To undo every change that has happened since a given commit occurred, use git reset. In the specific case where a developer needs to undo only the previous commit, either of the git revert or git reset commands will suffice.
🌐
Nick Janetakis
nickjanetakis.com › blog › undo-remove-or-revert-specific-git-commits
Undo, Remove or Revert Specific Git Commits — Nick Janetakis
July 1, 2025 - In the end this will add a new commit which is why it’s safe to do on pushed commits. It’s not rewriting history. You can check it out by running git show afterwards. Like the other examples you can replace HEAD~N with the GIT_SHA but this time around you don’t want to put the ^, it will already target the SHA we want. If you want to revert the oldest commit, you can use the GIT_SHA and it will work out of the box, but you wouldn’t be able to use HEAD~3 (the oldest commit in our old example).
🌐
GitProtect.io
gitprotect.io › strona główna › how to undo a commit in git
How to Undo a Commit in Git - Blog | GitProtect.io
January 7, 2026 - Then, don’t read but watch our GitProtect Academy video to find out how to undo a commit in git (Psst, don’t forget to subscribe!) So how can we undo changes that already exist outside? Fortunately, there is a safe solution – the git revert command operation. With it, we can undo changes from a specific commit.
🌐
Git
git-scm.com › docs › git-revert.html
Git - git-revert Documentation
If you want to throw away all uncommitted changes in your working directory, you should see git-reset[1], particularly the --hard option. If you want to extract specific files as they were in another commit, you should see git-restore[1], specifically the --source option.
🌐
Atlassian
atlassian.com › git › tutorials › undoing changes › git revert
How to Revert a Commit in Git? | Atlassian Git Tutorial
A revert operation will take the specified commit, inverse the changes from that commit, and create a new "revert commit". The ref pointers are then updated to point at the new revert commit making it the tip of the branch. To demonstrate let’s create an example repo using the command line ...
🌐
freeCodeCamp
freecodecamp.org › news › git-revert-file-reverting-a-file-to-a-previous-commit
Git Revert File – Reverting a File to a Previous Commit
November 7, 2024 - This will return only commits for the specified file and the commit SHA hash followed by the commit message. You will use the SHA hash to revert your file: 198d425 (HEAD -> main) initial c368a1c new removal bcbef35 updated readme 2 da9cc5f (origin/main) updated Readme a5150af first commit · So now that you know how to get the SHA code, you can use the git checkout command to revert your file to any commit you want by also passing the file name or file path:
🌐
Medium
devdiaryacademy.medium.com › git-rollback-resetting-a-branch-to-a-specific-commit-a-case-study-19daf94c2c78
Git Rollback: Resetting a Branch to a Specific Commit — A Case Study | by Developer Diary | Medium
February 10, 2026 - Replace <commit_id> with the actual commit ID you identified in Step 1. The git reset --hard command will reset your local "development" branch to the specified commit, discarding all commits made after it.
🌐
30 Seconds of Code
30secondsofcode.org › home › git › branch › rewind to commit
Rewind back to a specific commit in Git - 30 seconds of code
May 26, 2023 - To rewind back to a specific commit, you can use git reset. This command will uncommit and unstage changes, but leave them in the working directory.
🌐
Built In
builtin.com › articles › git-revert-a-file
Git Revert a File: A Guide | Built In
Find the path to the file you want to revert from the working directory. In the terminal, change directories to the working directory. Type git checkout [commit ID] -- path/to/file and hit enter.
🌐
ComfyUI
docs.comfy.org › get started › local (self-hosted) › how to update comfyui
How to Update ComfyUI - ComfyUI
June 17, 2026 - # View commit history git log --oneline # Switch to specific commit git checkout <commit-hash> # Return to latest version git checkout master
🌐
Pete Houston
blog.petehouston.com › home › coding › programming tips › revert git to a specific commit
Revert Git to a specific commit ⋆ Pete Houston
August 26, 2018 - To fix it, follow these steps: Create a backup branch for safety reason. $ git checkout -b backup Reset to a specific commit $ git reset --hard COMMIT_ID Force push to server to override the […]