What is the difference between `git reset` and `git revert`?
BeginnerConceptUndoing changes: reset, revert, restore and reflog
Answer
reset moves the branch pointer backwards and rewrites history, which is fine locally but disruptive on shared branches. revert adds a new commit that applies the inverse of an earlier commit, so history stays intact and it is safe on pushed branches.
git revert abc1234
git revert HEAD~3..HEAD
More on Undoing changes: reset, revert, restore and reflog
What are the three modes of `git reset`?BeginnerHow do you discard changes in one file?BeginnerHow do you recover a commit after `git reset --hard`?IntermediateCan you recover uncommitted changes lost by `git reset --hard` or `git checkout .`?IntermediateWhat does `git commit --amend` do to the reflog and to the old commit?IntermediateHow do you undo `git add` for a file?Beginner