[git] git revert back to certain commit

how do i revert all my files on my local copy back to a certain commit?

commit 4a155e5b3b4548f5f8139b5210b9bb477fa549de
Author: John Doe <[email protected]>
Date:   Thu Jul 21 20:51:38 2011 -0500

This is the commit i'd like to revert back to. any help would be a lifesaver!

This question is related to git commit revert

The answer is


You can revert all your files under your working directory and index by typing following this command

git reset --hard <SHAsum of your commit>

You can also type

git reset --hard HEAD #your current head point

or

git reset --hard HEAD^ #your previous head point

Hope it helps


http://www.kernel.org/pub/software/scm/git/docs/git-revert.html

using git revert <commit> will create a new commit that reverts the one you dont want to have.

You can specify a list of commits to revert.

An alternative: http://git-scm.com/docs/git-reset

git reset will reset your copy to the commit you want.


Examples related to git

Does the target directory for a git clone have to match the repo name? Git fatal: protocol 'https' is not supported Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) git clone: Authentication failed for <URL> destination path already exists and is not an empty directory SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443 GitLab remote: HTTP Basic: Access denied and fatal Authentication How can I switch to another branch in git? VS 2017 Git Local Commit DB.lock error on every commit How to remove an unpushed outgoing commit in Visual Studio?

Examples related to commit

git: updates were rejected because the remote contains work that you do not have locally How to add multiple files to Git at the same time Why Git is not allowing me to commit even after configuration? Git commit in terminal opens VIM, but can't get back to terminal How to configure Git post commit hook GIT commit as different user without email / or only email Editing the git commit message in GitHub How to amend a commit without changing commit message (reusing the previous one)? Temporarily switch working copy to a specific Git commit git - Your branch is ahead of 'origin/master' by 1 commit

Examples related to revert

How do you revert to a specific tag in Git? How do I revert an SVN commit? How do I "un-revert" a reverted Git commit? git revert back to certain commit Reverting to a previous revision using TortoiseSVN Remove specific commit Reverting single file in SVN to a particular revision How can I revert a single file to a previous version? Mercurial — revert back to old version and continue from there git status shows modifications, git checkout -- <file> doesn't remove them