LEARN / GUIDE
Git restore, revert and reset
restore updates working-tree files or the index. revert records a new commit that reverses an earlier commit. reset moves a reference and may also change the index and working tree.
What to remember
restore can discard uncommitted work. reset --hard can discard tracked changes. Review git status and keep a backup before recovery operations. Reverting a merge requires selecting a mainline parent.
An example to inspect
git status --shortgit restore --source HEAD -- ./src/app.tsTry the related tool ↗Examples target GNU/Linux and Bash. Read your locally installed manual before applying commands to important data.