Skip to content

Commit 613f1f8

Browse files
committed
Add Extend Git With Custom Commands as a git TIL
1 parent e86c36e commit 613f1f8

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

README.md

+2-1
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-
_1370 TILs and counting..._
13+
_1371 TILs and counting..._
1414

1515
---
1616

@@ -271,6 +271,7 @@ _1370 TILs and counting..._
271271
- [Dry Runs in Git](git/dry-runs-in-git.md)
272272
- [Exclude A File From A Diff Output](git/exclude-a-file-from-a-diff-output.md)
273273
- [Excluding Files Locally](git/excluding-files-locally.md)
274+
- [Extend Git With Custom Commands](git/extend-git-with-custom-commands.md)
274275
- [Find And Remove Files That Match A Name](git/find-and-remove-files-that-match-a-name.md)
275276
- [Find The Date That A File Was Added To The Repo](git/find-the-date-that-a-file-was-added-to-the-repo.md)
276277
- [Find The Initial Commit](git/find-the-initial-commit.md)
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Extend Git With Custom Commands
2+
3+
I recently learned about the [`git
4+
absorb`](https://github.com/tummychow/git-absorb) command. It is interesting in
5+
its own right, but I bring it up because it isn't a command that is built in to
6+
git. When I was looking at the installation instructions for it, it didn't say
7+
anything about how to _register_ the command with `git`.
8+
9+
How is git supposed to know about it? How do you extend git with custom
10+
commands?
11+
12+
What I learned exploring those questions is that `git` will execute any command
13+
on your _path_ with a `git-<command>` naming convention.
14+
15+
So, if I create a executable binary called `git-taco`, add it to my path, and
16+
then run `git taco` (notice, no dash when I run it), `git` will run my custom
17+
binary.
18+
19+
In the same way, if you download `git-absorb` and add it to your path, `git`
20+
will run it for you when you enter `git absorb ...`.
21+
22+
You can even type something like `where git-` and then hit tab to prompt your
23+
shell to display a list of a varity of other `git` commands, most of which
24+
probably ship with `git`.
25+
26+
[source](https://twitter.com/jbrancha/status/1756361704160530555)

0 commit comments

Comments
 (0)