Skip to content

Commit

Permalink
Revert a file to a specific revision (k88hudson#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
voxsim authored and RichardLitt committed Nov 13, 2017
1 parent a38b385 commit fc45952
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ For clarity's sake all examples in this document use a customized bash prompt in
- [Tracking Files](#tracking-files)
- [I want to change a file name's capitalization, without changing the contents of the file.](#i-want-to-change-a-file-names-capitalization-without-changing-the-contents-of-the-file)
- [I want to remove a file from git but keep the file](#i-want-to-remove-a-file-from-git-but-keep-the-file)
- [I want to revert a file to a specific revision](#i-want-to-revert-a-file-to-a-specific-revision)
- [Configuration](#configuration)
- [I want to add aliases for some git commands](#i-want-to-add-aliases-for-some-git-commands)
- [I want to cache a username and password for a repository](#i-want-to-cache-a-username-and-password-for-a-repository)
Expand Down Expand Up @@ -928,6 +929,21 @@ From github.com:foo/bar
(master)$ git rm --cached log.txt
```

<a href="i-want-to-revert-a-file-to-a-specific-revision"></a>
### I want to revert a file to a specific revision

Assuming the hash of the commit you want is c5f567:

```sh
(master)$ git checkout c5f567 -- file1/to/restore file2/to/restore
```

If you want to revert to changes made just 1 commit before c5f567, pass the commit hash as c5f567~1:

```sh
(master)$ git checkout c5f567~1 -- file1/to/restore file2/to/restore
```

## Configuration

<a name="adding-command-aliases"></a>
Expand Down

0 comments on commit fc45952

Please sign in to comment.