File tree 2 files changed +34
-1
lines changed
2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
10
10
11
11
For a steady stream of TILs, [ sign up for my newsletter] ( https://crafty-builder-6996.ck.page/e169c61186 ) .
12
12
13
- _ 1542 TILs and counting..._
13
+ _ 1543 TILs and counting..._
14
14
15
15
---
16
16
@@ -1528,6 +1528,7 @@ _1542 TILs and counting..._
1528
1528
- [ Load Env Vars In Bash Script] ( unix/load-env-vars-in-bash-script.md )
1529
1529
- [ Look Through All Files That Have Been Git Stashed] ( unix/look-through-all-files-that-have-been-git-stashed.md )
1530
1530
- [ 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 )
1531
1532
- [ Map A Domain To localhost] ( unix/map-a-domain-to-localhost.md )
1532
1533
- [ Negative Look-Ahead Search With ripgrep] ( unix/negative-look-ahead-search-with-ripgrep.md )
1533
1534
- [ Occupy A Local Port With Netcat] ( unix/occupy-a-local-port-with-netcat.md )
Original file line number Diff line number Diff line change
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.
You can’t perform that action at this time.
0 commit comments