From fc459528eacd30bc27612b29eda3af32d11ff8b1 Mon Sep 17 00:00:00 2001 From: Simon Vocella Date: Mon, 13 Nov 2017 15:09:15 +0100 Subject: [PATCH] Revert a file to a specific revision (#131) --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index cf37602..339c932 100644 --- a/README.md +++ b/README.md @@ -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) @@ -928,6 +929,21 @@ From github.com:foo/bar (master)$ git rm --cached log.txt ``` + +### 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