git revert

From thelinuxwiki
Jump to: navigation, search

git revert will "restore" an older version of a file from the git repo onto disk into the working directory. this is not to be confused with git restore.

example

$ git revert 5b414ff8a4e014956939d06ba822795761f2f74d

will replace the file codefile.src with the version in the repo before the last commit by undoing it. the 40-byte hexadecimal string is the SHA-1 object name as show by git log.

example

$ git log

commit 5b414ff8a4e014956939d06ba822795761f2f74d Author: jsmith <jsmith@abccorp.com> Date: Sat Aug 29 05:46:57 2020 -0500
update codefile.src for new feater #87