What's the git equivalent of "svn update -r"?

GitSvnGit SvnGit CheckoutSvn Update

Git Problem Overview

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.

Git Solutions

Solution 1 - Git

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.

Solution 2 - Git

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.

Solution 3 - Git

git pull 
seems a more appropriate command for what you are looking for

Solution 4 - Git

This seems to do what I wanted, which is what I think you're asking for too

git checkout *

Solution 5 - Git

If you are using TortoiseGit then

Right Click in project folder > TortoiseGit > Pull

Solution 6 - Git

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 for git checkout HEAD~ -- .

  • Git 1.8.4 introduced @ as a shortcut notation for HEAD.

Solution 7 - Git

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.


All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionfratrikView Question on Stackoverflow
Solution 1 - GitBombeView Answer on Stackoverflow
Solution 2 - GitjmuView Answer on Stackoverflow
Solution 3 - GitBrrView Answer on Stackoverflow
Solution 4 - GitGoodyView Answer on Stackoverflow
Solution 5 - GitSandeep SinghView Answer on Stackoverflow
Solution 6 - GitVonCView Answer on Stackoverflow
Solution 7 - GitLoganath RajaView Answer on Stackoverflow