1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-03 07:08:01 +00:00

Add Show Only Commits That Touch Specific Lines as a git til

This commit is contained in:
jbranchaud
2019-01-31 10:55:29 -06:00
parent c4c029a8a2
commit 4abaea705a
2 changed files with 30 additions and 1 deletions

View File

@@ -10,7 +10,7 @@ smart people at [Hashrocket](http://hashrocket.com/).
For a steady stream of TILs from a variety of rocketeers, checkout For a steady stream of TILs from a variety of rocketeers, checkout
[til.hashrocket.com](https://til.hashrocket.com/). [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 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 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 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 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 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) - [Show What Is In A Stash](git/show-what-is-in-a-stash.md)

View File

@@ -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)