mirror of
https://github.com/jbranchaud/til
synced 2026-01-03 07:08:01 +00:00
Add Extend Git With Custom Commands as a git TIL
This commit is contained in:
@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
|
|||||||
|
|
||||||
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
|
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
|
||||||
|
|
||||||
_1370 TILs and counting..._
|
_1371 TILs and counting..._
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -271,6 +271,7 @@ _1370 TILs and counting..._
|
|||||||
- [Dry Runs in Git](git/dry-runs-in-git.md)
|
- [Dry Runs in Git](git/dry-runs-in-git.md)
|
||||||
- [Exclude A File From A Diff Output](git/exclude-a-file-from-a-diff-output.md)
|
- [Exclude A File From A Diff Output](git/exclude-a-file-from-a-diff-output.md)
|
||||||
- [Excluding Files Locally](git/excluding-files-locally.md)
|
- [Excluding Files Locally](git/excluding-files-locally.md)
|
||||||
|
- [Extend Git With Custom Commands](git/extend-git-with-custom-commands.md)
|
||||||
- [Find And Remove Files That Match A Name](git/find-and-remove-files-that-match-a-name.md)
|
- [Find And Remove Files That Match A Name](git/find-and-remove-files-that-match-a-name.md)
|
||||||
- [Find The Date That A File Was Added To The Repo](git/find-the-date-that-a-file-was-added-to-the-repo.md)
|
- [Find The Date That A File Was Added To The Repo](git/find-the-date-that-a-file-was-added-to-the-repo.md)
|
||||||
- [Find The Initial Commit](git/find-the-initial-commit.md)
|
- [Find The Initial Commit](git/find-the-initial-commit.md)
|
||||||
|
|||||||
26
git/extend-git-with-custom-commands.md
Normal file
26
git/extend-git-with-custom-commands.md
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
# Extend Git With Custom Commands
|
||||||
|
|
||||||
|
I recently learned about the [`git
|
||||||
|
absorb`](https://github.com/tummychow/git-absorb) command. It is interesting in
|
||||||
|
its own right, but I bring it up because it isn't a command that is built in to
|
||||||
|
git. When I was looking at the installation instructions for it, it didn't say
|
||||||
|
anything about how to _register_ the command with `git`.
|
||||||
|
|
||||||
|
How is git supposed to know about it? How do you extend git with custom
|
||||||
|
commands?
|
||||||
|
|
||||||
|
What I learned exploring those questions is that `git` will execute any command
|
||||||
|
on your _path_ with a `git-<command>` naming convention.
|
||||||
|
|
||||||
|
So, if I create a executable binary called `git-taco`, add it to my path, and
|
||||||
|
then run `git taco` (notice, no dash when I run it), `git` will run my custom
|
||||||
|
binary.
|
||||||
|
|
||||||
|
In the same way, if you download `git-absorb` and add it to your path, `git`
|
||||||
|
will run it for you when you enter `git absorb ...`.
|
||||||
|
|
||||||
|
You can even type something like `where git-` and then hit tab to prompt your
|
||||||
|
shell to display a list of a varity of other `git` commands, most of which
|
||||||
|
probably ship with `git`.
|
||||||
|
|
||||||
|
[source](https://twitter.com/jbrancha/status/1756361704160530555)
|
||||||
Reference in New Issue
Block a user