From 2e3474eef0a2f65e5ba37a8338c8e14a651fa3c5 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Thu, 18 Jun 2015 08:23:32 -0500 Subject: [PATCH] Add Last Commit A File Appeared In as a git til. --- README.md | 1 + git/last-commit-a-file-appeared-in.md | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 git/last-commit-a-file-appeared-in.md diff --git a/README.md b/README.md index c79d9a9..88e2400 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ smart people at [Hashrocket](http://hashrocket.com/). - [Delete All Untracked Files](git/delete-all-untracked-files.md) - [Dry Runs in Git](git/dry-runs-in-git.md) - [Intent To Add](git/intent-to-add.md) +- [Last Commit A File Appeared In](git/last-commit-a-file-appeared-in.md) - [List Filenames Without The Diffs](git/list-filenames-without-the-diffs.md) - [List Untracked Files](git/list-untracked-files.md) - [Single Key Presses in Interactive Mode](git/single-key-presses-in-interactive-mode.md) diff --git a/git/last-commit-a-file-appeared-in.md b/git/last-commit-a-file-appeared-in.md new file mode 100644 index 0000000..462051d --- /dev/null +++ b/git/last-commit-a-file-appeared-in.md @@ -0,0 +1,27 @@ +# Last Commit A File Appeared In + +In my project, I have a `README.md` file that I haven't modified in a while. +I'd like to take a look at the last commit that modified it. The `git log` +command can be used here with few arguments to narrow it down. + +``` +$ git log -1 -- README.md +commit 6da76838549a43aa578604f8d0eee7f6dbf44168 +Author: jbranchaud +Date: Sun May 17 12:08:02 2015 -0500 + + Add some documentation on configuring basic auth. +``` + +This same command will even work for files that have been deleted if you +know the path and name of the file in question. For instance, I used to have +an `ideas.md` file and I'd like to find the commit that removed it. + +``` +$ git log -1 -- docs/ideas.md +commit 0bb1d80ea8123dd12c305394e61ae27bdb706434 +Author: jbranchaud +Date: Sat May 16 14:53:57 2015 -0500 + + Remove the ideas doc, it isn't needed anymore. +```