From 3e5c300cc148598fd1c2f0151454ead4bd6b70ab Mon Sep 17 00:00:00 2001 From: Mica White Date: Thu, 24 Sep 2026 18:21:16 -0400 Subject: Update shakefile --- src/blog/git-plugins.kuht | 71 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 src/blog/git-plugins.kuht (limited to 'src') diff --git a/src/blog/git-plugins.kuht b/src/blog/git-plugins.kuht new file mode 100644 index 0000000..b26648a --- /dev/null +++ b/src/blog/git-plugins.kuht @@ -0,0 +1,71 @@ + + + + Make Yourself Some Git Plugins + + + + + +
+ +

Make Yourself Some Git Plugins

+ +

You may already be aware of some popular git plugins:

+ + +

+ Many of you likely already know how to implement such a plugin, but I want to + provide a short tutorial for everyone else. +

+ +

+ A command that I often find useful is git publish. If the branch + doesn't already exist on the remote, it's nice to be able to have an alias for + git push --set-upstream origin $BRANCH_NAME. Some plugins do this + automatically, but it's very easy to write, so there's not much reason we + can't implement it ourselves. +

+ +
+#!/usr/bin/env sh
+
+BRANCH=${git rev-parse --abbrev-ref HEAD}
+git push --set-upstream origin $BRANCH
+
+ +

+ Now that we have that, we can make it accessible to Git. The easiest way to do + this is to put the script in your ~/.local/bin directory, since + it's usually already in the PATH. We'll call the full file: + ~/.local/bin/git-publish. We won't add a .sh file + extension, because the shebang already tells the OS how to run this program. +

+ +

+ Then we just need to make the program executable. Run + chmod +x ~/.local/bin/git-publish, and you're done. We can now + run it as git publish. When Git sees the publish + command, it will look through the path to see if an executable called + git-publish exists, and run that. +

+ +

+ See how easy that was? If you want to do something more complicated with Git, + I recommend reading the + Git Internals + chapter from Pro Git. Git is + really more of a database than a version control system, and I'm always + disappointed by the lack of creativity people put into git plugins. Writing a + sillier project would be too long for this blog post, but it'd be cool to see + someone make an MMO using Git as the database. The sky is the limit. +

-- cgit v1.3.1