TIL: Using git restore to Revert File Changes and Sync with Another Branch
Contents
Today I learned that if you need to revert a specific file to its original state, even after commits, or if you want to sync a file with another branch, you can use the
git restore
command.
The git restore
command allows you to revert a file to its previous state or sync it with a different branch. This can be particularly useful when you need to discard changes and align a file with its version from another branch, such as main.
In this example, I want to restore and discard all committed changes in my current branch for a specific file to match the version from the main branch:
|
|
- git-restore documentation
- Cover image is licensed with Creative Commons Attribution 3.0 Unported and source