Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • For this simple use case, which every other version control system just calls "revert", why is the Git command so obscure? Commented Jun 17, 2011 at 2:54
  • 6
    @Jan Do other version control systems' revert command allow you to select which changes within a file are reverted? Genuinely asking, as I only have experience with CVS and Git. In Git, git checkout -- path/to/file is a single command that reverts all changes in that file, but this is not the same as above. Commented Jun 28, 2011 at 2:54
  • 3
    There's also git checkout --patch and git reset --patch which work like git add --patch in latest git. Commented Oct 31, 2012 at 5:01
  • 2
    @Rudie, the -- usually indicate the end of options parsing, and that any arguments that come after it are to be interpreted literally. This means that you wouldn't have to add ./ before any filename that starts with a minus sign, if the filename comes after --. Commented Jan 29, 2014 at 13:12
  • when i use git checkout --patch the diff appears to be backwards. The minus symbols are ADDING text to my working copy, and the plus symbols are REMOVING lines from my working copy. Commented Oct 30, 2017 at 1:01