diff --git a/README.md b/README.md index 7bf773c..e506e56 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ smart people at [Hashrocket](http://hashrocket.com/). For a steady stream of TILs from a variety of rocketeers, checkout [til.hashrocket.com](https://til.hashrocket.com/). -_749 TILs and counting..._ +_750 TILs and counting..._ --- @@ -202,6 +202,7 @@ _749 TILs and counting..._ - [Show Changes In The Compose Commit Message View](git/show-changes-in-the-compose-commit-message-view.md) - [Show File Diffs When Viewing Git Log](git/show-file-diffs-when-viewing-git-log.md) - [Show List Of Most Recently Committed Branches](git/show-list-of-most-recently-committed-branches.md) +- [Show Only Commits That Touch Specific Lines](git/show-only-commits-that-touch-specific-lines.md) - [Show The diffstat Summary Of A Commit](git/show-the-diffstat-summary-of-a-commit.md) - [Show The Good And The Bad With Git Bisect](git/show-the-good-and-the-bad-with-git-bisect.md) - [Show What Is In A Stash](git/show-what-is-in-a-stash.md) diff --git a/git/show-only-commits-that-touch-specific-lines.md b/git/show-only-commits-that-touch-specific-lines.md new file mode 100644 index 0000000..7f23db6 --- /dev/null +++ b/git/show-only-commits-that-touch-specific-lines.md @@ -0,0 +1,28 @@ +# Show Only Commits That Touch Specific Lines + +When you run `git log`, you are listing all commits in reverse-chronological +order for the current branch. There are ways of filtering the commits that +get output from `git-log`. As of Git 1.8.4, `git-log` output can be filtered +by commits that touch a range of line numbers. + +This is done with the `-L` flag. + +For instance, if I want to see all commits that touched the 13th line of my +`README.md` file, then I can do this: + +```bash +$ git log -L13,13:README.md +``` + +I can alter the command to show commits that touched a range of lines like +so: + +```bash +$ git log -L19,45:README.md +``` + +I used the `-L` flag recently to find when a dependency was added to my +`package.json` file even though the most recent changes to that line were +version bumps. + +[source](https://stackoverflow.com/questions/8435343/retrieve-the-commit-log-for-a-specific-line-in-a-file)