alexkarle.com

Source for alexkarle.com
git clone git://git.alexkarle.com/alexkarle.com.git
Log | Files | Refs | README | LICENSE

commit 6ac273d5bbee293ed78026c7f150c26c6240c128 (patch)
parent 5afe18f3470e484fdb51dc2fe18ec87ec5e5f5c0
Author: Alex Karle <alex@alexkarle.com>
Date:   Sun,  7 Nov 2021 17:29:07 -0500

blog: Publish new post on non-standard git usage

This is top of mind because:

  1. Anthony is encouraging me to blog more
  2. I had a long call with my dad about his notetaking system
     and the lack of backups (just use git!)

My dad's reaction when I suggested he use git (good idea!) made me
feel like something worth writing about :)

Diffstat:
MORDER | 1+
Mblog.7 | 4++++
Ause-git.7 | 141+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 146 insertions(+), 0 deletions(-)

diff --git a/ORDER b/ORDER @@ -14,3 +14,4 @@ 109-creative-coding.txt 110-text-only.txt 111-make-obj.txt +112-use-git.txt diff --git a/blog.7 b/blog.7 @@ -15,6 +15,10 @@ For an up to date list of software/hardware I use, see .Xr uses 7 . .Sh POSTS .Bl -tag -width "XX/XX" +.It 11/21 +.Xr use-git 7 +- non-standard uses of +.Xr git 1 .It 09/21 .Xr make-obj 7 - out-of-tree builds with BSD diff --git a/use-git.7 b/use-git.7 @@ -0,0 +1,141 @@ +.Dd November 07, 2021 +.Dt USE-GIT 7 +.Os +.Sh NAME +.Nm use-git +.Nd non-standard uses for +.Xr git 1 +.Sh DESCRIPTION +In this post, +I'm not going to teach you how to use +.Xr git 1 . +Instead, +I wanted to write a quick post to encourage you to use git +for non-conventional use cases +(i.e. things other than source code). +.Pp +If perchance you're not familiar with git, +there's a ton of good documentation out there. +I'd recommend starting with the official and free +.Lk https://git-scm.com/book/en/v2 Pro Git . +Also, +as a PSA, +just know that git stores whole snapshots and NOT diffs. +.Pp +.Sh BACKGROUND +Git is a distributed version control system, +and this is a beautiful thing. +I feel it's often lost on us, +given that we use it most frequently on centralized forges +for team collaboration (GitHub, GitLab, etc). +.Pp +Git being distributed means you can: +.Pp +.Bl -enum -compact +.It +Use it offline (your copy is "first class") +.It +Mirror it to as many places as you want +.El +.Pp +In other words, +git can be used without any dependence on a third-party +service or company and with complete ownership of private data. +Forges (and I recommend +.Lk https://sourcehut.org ) +are a great place to backup your code and collaborate, +but you don't have to use a forge to use git as a futureproof way to do what +it does best: version your files. +.Sh STORY TIME +When I started my first job in tech, +I found that it was a good habit to take personal notes. +It was incredibly useful to quickly reference obscure CLI +commands or system knowledge gained from pairing. +These were things that were too small or personal to make it into +standard documentation +but invaluable to have on hand. +.Pp +My first solution was shoving them all into a directory called +.Pa ~/notes +as plaintext files. +They were easy to write and reference, +and it was simple to back them up by copying the directory +to another drive nightly. +.Pp +Over time, +the +.Ql cp -a +trick broke down: +.Pp +.Bl -bullet -compact +.It +Files deleted in the source prevailed in the backup +.It +Changes more than a day old were lost! +.El +.Pp +Around the same time, +I started getting more familiar with git, +and it finally occurred to me: +I could use git and still keep these notes private! +.Pp +Git can clone/push/pull across filesystems, +so in the matter of minutes I solved both of my issues +with just: +.Bd -literal -offset indent +# Set up the backup mirror +$ git init --bare /backup/drive/notes.git + +# Put it to use! +$ cd ~/notes +$ git init && git add . && git commit -m "import" +$ git remote add origin /backup/drive/notes.git +$ git push -u origin main +.Ed +.Pp +If you don't have a backup drive mounted, +it's equally good (or better) to make the remote a repo +accessed over SSH: +.Bd -literal -offset indent +# On the remote host +user@example.com~$ git init --bare ~/notes.git + +# On the local host +$ git remote add origin user@example.com:notes.git +.Ed +.Sh GOING FURTHER +These days, +I shudder at the thought of any important plaintext on my system +that's not version-controlled somewhere. +Too many hours are spent writing these little files, +and it's so easy to version them, +why risk losing any of that history? +.Pp +Aside from my private notes, I version: +.Pp +.Bl -bullet -compact +.It +System config files from /etc +.It +Personal config files (dotfiles) +.It +My passwords (via +.Xr pass 1 ) +.It +A small set of personal patches for FOSS projects I have yet to polish and upstream (a-la ports-system) +.It +My resume (admittedly still a DOCX from college, but versioning has really helped) +.El +.Pp +In conclusion, +my advice to anyone writing anything of importance: +just use +.Xr git 1 ! +.Sh SEE ALSO +.Bl -bullet -compact +.It +.Xr blog 7 +.It +.Lk https://github.blog/2020-12-17-commits-are-snapshots-not-diffs/ Commits are snapshots, not diffs +by Derrick Stolee +.El