Generally there are three ways of reverting changes:
- checkout
- revert
- reset
Checkout
If you just need to revert specific files, you could run git checkout to retrieve an exact version. In the below example, I wanted to revert the “app.rb” file so that it only contains “Some app work.
Revert
Revert will create a new commit undoing the changes made during a specific commit. It remove an entire commit in your project history. In this example, I’m going to undo the changes in last commit. As you could see, the history of the revert is kept.
Reset
Unlike revert, reset will undo all subsequent commits. It has the potential Only use this to undo local changes. Most use reset to unstage files to match the most recent commit and perhaps create more focused commits/snapshots. The working directory is unchanged unless “–hard” option is set.
Recent Comments