Skip to content

Commit 8801f39

Browse files
committed
Add Manually Pass Two Git Files To Delta as a Unix TIL
1 parent aeb55ef commit 8801f39

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
1010

1111
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
1212

13-
_1542 TILs and counting..._
13+
_1543 TILs and counting..._
1414

1515
---
1616

@@ -1528,6 +1528,7 @@ _1542 TILs and counting..._
15281528
- [Load Env Vars In Bash Script](unix/load-env-vars-in-bash-script.md)
15291529
- [Look Through All Files That Have Been Git Stashed](unix/look-through-all-files-that-have-been-git-stashed.md)
15301530
- [Make Direnv Less Noisy](unix/make-direnv-less-noisy.md)
1531+
- [Manually Pass Two Git Files To Delta](unix/manually-pass-two-git-files-to-delta.md)
15311532
- [Map A Domain To localhost](unix/map-a-domain-to-localhost.md)
15321533
- [Negative Look-Ahead Search With ripgrep](unix/negative-look-ahead-search-with-ripgrep.md)
15331534
- [Occupy A Local Port With Netcat](unix/occupy-a-local-port-with-netcat.md)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Manually Pass Two Git Files To Delta
2+
3+
I recently [wired up `delta` as my default pager and differ for
4+
`git`](git/better-diffs-with-delta.md). However, when I installed `delta`, I
5+
first wanted to see what its diff output looked like.
6+
7+
How can I pass two versions of the same file from `git` to `delta`?
8+
9+
I can show the current contents of a file with `git show` referencing the
10+
`HEAD` commit.
11+
12+
```bash
13+
$ git show HEAD:main.go
14+
```
15+
16+
Similiarly, I can show the contents of that file _one_ commit ago with `HEAD~`.
17+
18+
```bash
19+
$ git show HEAD~:main.go
20+
```
21+
22+
I can then pass each of those commands as virtual files to `delta` using the
23+
`<()` syntax. The older file goes first and the newer second.
24+
25+
```bash
26+
$ delta <(git show HEAD~:main.go) <(git show HEAD:main.go)
27+
```
28+
29+
That works and comes in handy if you need to compare two things that aren't
30+
necessarily files or aren't necessarily under version control. However, in
31+
hindsight, I'd say it is easier to add delta as the pager and differ and try it
32+
out directly.

0 commit comments

Comments
 (0)