Benefits of a Git-backed Blog

Several months ago when I first started using git, I made a terrible mistake. It was one of the first command-line tools I had used, and I didn't realize "git init" was invoked on the current directory. So I ran it on my home directory, thinking that some time later git would prompt me for the path for the repo. After a "git add .", I had added all the files and folders from my home directory into the repo.

I started to get a feeling this wasn't right, and so I googled around for a way to undo the add. I found the "unstage" command, so I ran that. So then I had a git repo with a bunch of unstaged files, and I could still see all the unstaged files listed when I ran "git status." I was beginning to understand a little of how git worked, but wanted to clean out that repo. Well, simple, "git clean." I assumed that git only held references to my files, and this clean command would just reset the repo. So I ran "git clean -f -d."

Well the -f was "force," and the -d was "all files in all directories." Since my home directory was a repo, what I had done when I unstaged the files was tell git that those files were not part of this repo. Then "git clean" gets rid of everything that is not part of the repo.

More precisely, "git clean" will permanently and irrevocably delete all files that are not a part of the repo. I was mistaken in my assumption that git would not have any real affect on the file structure, and several minutes into the cleaning process I decided to kill the terminal session, since my poor laptop was thinking way too hard for it to just be removing a superfluous set of references.

And that's how I wiped out my home directory.

Fast forward a bit, and after more resarch and learning, I've come back to git. This time, vim is no longer a foreign world, and I've got a better grasp of how to use command line tools.

In the past day, I've learned how to generate a static blog, create a local git repo including the static content, install git on a confounding godaddy shared host, create a remote repository on the server, configure ssh, create a post-receive hook on the server to automatically checkout the content to the document root, and create a post-commit hook in my local repo to automatically push the new site to the server after a commit.

So for me, one of the main benefits of blogging this way is that it teaches me git. As a self-taught independent developer, I haven't come across a ton of situations where I needed to use git. I've been using the git integration in Xcode, but only because it's so easy to use. For the first time I'm starting to really understand it, and I've only scratched the surface.

It's also remarkably fun. For anyone interested in git, vim, and markdown, I'd definitely reccomend it. It's a great way to learn git on your own.

Comments:

rss

blog powered by Pelican