I'm a recent git convert. It's great to be able to use git-svn to keep my branches locally without disturbing the svn server. There was a bug that existed in the latest version of the code. I wanted to establish a time when it worked so that I could use git bisect. I couldn't find the right command to move back in time. Thanks.
7 Answers
git checkout HEAD~1
This will move your current HEAD to one revision earlier.
git checkout <sha>
This will move your current HEAD to the given revision. Use git log
or gitk
to find the revision you’re looking for.

- 81,643
- 20
- 123
- 127
-
2Although I executed both these commands, I'm not seeing my files. Here's the situation. 1.) I delete a folder. 2.) I do the two commands you've listed. 3.) The folder is still deleted instead being pulled down as an SVN update would have restored. – Danny Nov 05 '12 at 21:59
-
2That’s because what you are looking for is `git checkout --
`. – Bombe Nov 06 '12 at 06:07
And getting back to latest (equivalent to: svn up), you'll need to update the branch, usually:
git checkout master
This is because the HEAD refers to the version that is being checked out.

- 3,619
- 1
- 23
- 12
-
5This doesn't seem to be the equivalent of svn up. In svn, if I edit something and want to just clear it out and return to the current repository version, I just delete the file and do svn up. Then the current version of the file I just deleted gets pulled from the repository. This doesn't happen with git checkout master. It just tells me the filed is deleted. How do I get a deleted file back? – mutatron Apr 04 '13 at 14:53
-
4One can revert changes (including locally deleted files) by checking out the file in question: `git checkout myfile.txt` – jmu Apr 18 '13 at 05:10
This seems to do what I wanted, which is what I think you're asking for too
git checkout *

- 381
- 1
- 2
- 10
If you are using TortoiseGit then
Right Click in project folder > TortoiseGit > Pull

- 7,790
- 4
- 43
- 68
Update 2019: the proper command would be
git restore -s @~1
(to, for instance, restore files at their state in HEAD parent commit)
That is because:
git checkout
is too confusing, dealing both with branches and files.
git restore
only... restore files, since Git 2.23 (August 2019).
No need forgit checkout HEAD~ -- .
- Git 1.8.4 introduced
@
as a shortcut notation forHEAD
.

- 1,262,500
- 529
- 4,410
- 5,250
There is no exact equivalent of svn update in git. If you delete a file, it will show as deleted status even if you pull it again. Only option is to checkout that file. If you have deleted multiple files by mistake and want to bring back them, You could rename that repo and clone it once again. This is what i do.

- 23
- 1
- 3