mirror of
https://github.com/jbranchaud/til
synced 2026-01-07 09:08:01 +00:00
Add Show All Commits For A File Beyond Renaming as a git til
This commit is contained in:
@@ -96,6 +96,7 @@ _349 TILs and counting..._
|
|||||||
- [Reference A Commit Via Commit Message Pattern Matching](git/reference-a-commit-via-commit-message-pattern-matching.md)
|
- [Reference A Commit Via Commit Message Pattern Matching](git/reference-a-commit-via-commit-message-pattern-matching.md)
|
||||||
- [Renaming A Branch](git/renaming-a-branch.md)
|
- [Renaming A Branch](git/renaming-a-branch.md)
|
||||||
- [Resetting A Reset](git/resetting-a-reset.md)
|
- [Resetting A Reset](git/resetting-a-reset.md)
|
||||||
|
- [Show All Commits For A File Beyond Renaming](git/show-all-commits-for-a-file-beyond-renaming.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)
|
||||||
- [Single Key Presses in Interactive Mode](git/single-key-presses-in-interactive-mode.md)
|
- [Single Key Presses in Interactive Mode](git/single-key-presses-in-interactive-mode.md)
|
||||||
- [Staging Changes Within Vim](git/staging-changes-within-vim.md)
|
- [Staging Changes Within Vim](git/staging-changes-within-vim.md)
|
||||||
|
|||||||
45
git/show-all-commits-for-a-file-beyond-renaming.md
Normal file
45
git/show-all-commits-for-a-file-beyond-renaming.md
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
# Show All Commits For A File Beyond Renaming
|
||||||
|
|
||||||
|
By including `-- <filename>` with a `git log` command, we can list all the
|
||||||
|
commits for a file. The following is an example of such a command with some
|
||||||
|
formatting and file names.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
> git log --name-only --pretty=format:%H -- README.md
|
||||||
|
4e57c5d46637286731dc7fbb1e16330f1f3b2b7c
|
||||||
|
README.md
|
||||||
|
|
||||||
|
56955ff027f02b57212476e142a97ce2b7e60efe
|
||||||
|
README.md
|
||||||
|
|
||||||
|
5abdc5106529dd246450b381f621fa1b05808830
|
||||||
|
README.md
|
||||||
|
```
|
||||||
|
|
||||||
|
What we may not realize though, is that we are missing out on a commit in
|
||||||
|
this file's history. At one point, this file was renamed. The command above
|
||||||
|
wasn't able to capture that.
|
||||||
|
|
||||||
|
Using the `--follow` flag with a file name, we can list all commits for a
|
||||||
|
file beyond renaming.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
> git log --name-only --pretty=format:%H --follow README.md
|
||||||
|
4e57c5d46637286731dc7fbb1e16330f1f3b2b7c
|
||||||
|
README.md
|
||||||
|
|
||||||
|
56955ff027f02b57212476e142a97ce2b7e60efe
|
||||||
|
README.md
|
||||||
|
|
||||||
|
5abdc5106529dd246450b381f621fa1b05808830
|
||||||
|
README.md
|
||||||
|
|
||||||
|
ea885f458b0d525f673623f2440de9556954c0c9
|
||||||
|
README.rdoc
|
||||||
|
```
|
||||||
|
|
||||||
|
This command roped in a commit from when `README.md` used to be called
|
||||||
|
`README.rdoc`. If you want to know about the *full* history of a file, this
|
||||||
|
is the way to go.
|
||||||
|
|
||||||
|
[source](http://stackoverflow.com/questions/3701404/list-all-commits-for-a-specific-file)
|
||||||
Reference in New Issue
Block a user