Want to undo your previous commit with a git revert?
Want to keep your old commit but start fresh? Then you want to revert a git commit instead of an amend or a reset.
The benefit of the git revert when you undo a commit is that it keeps your old commit, undoes changes, and then creates a new commit for you. This way no history is lost, and you don't have to worry about messing up the git commit history when you push back to GitHub or GitLab.
Compare this to when you undo a commit with reset or amend instead of the git revert command. In those other cases, you end up with orphan commits that can really mess up remote repositories.
To undo your last commit, git revert the changes. It's the best option!
Watch video Git Revert a Commit online, duration hours minute second in high quality that is uploaded to the channel Cameron McKenzie 26 November 2023. Share the link to the video on social media so that your subscribers and friends will also watch this video. This video clip has been viewed 3,222 times and liked it 85 visitors.