Artisanal Handcrafted Git Repositories

https://news.ycombinator.com/rss Hits: 22
Summary

There’s no love and care put into crafting our git repositories nowadays. Let’s change that. I’m going to talk about how to handmake your git repositories without using these silly git commands. You might also learn a bit more about how git works under the hood during the process, or whatever. If you’re so inclined, you might also take it as an opportunity to appreciate how the power of git comes not from the complexity of its code but from the simplicity and elegance of its design. I mean, if that’s your thing. Git refers to the user-friendly commands as “porcelain” and to the internals as “plumbing”, so you can think of this as an introductory lesson in git plumbing. In fact, git has “plumbing” commands which we’re not even using, so this is more like an introductory course in git fluid dynamics. In other words, it’s pretty silly. #Pre-requisites I’m going to assume you are familiar with git and are comfortable in a shell environment, otherwise this probably won’t make much sense to you. #Let’s get started The first thing we’d do normally is run git init, but where’s the care and attention in that? We’re going to do it the old-fashioned way, like the pilgrims of yore would’ve done. # This is where git stores all the information for a repository, from branches to# Git expects these folders to exist, but we don't need to add anything into them yet.$ mkdir -p .git/hooks .git/info .git/objects/info .git/objects/pack .git/refs/heads .git/refs/remotes .git/refs/tags .git/logs# This is just a standard repo-specific config file – these are the default values on my$ cat <<EOF > .git/config repositoryformatversion = 0 Now we only have to add one more file before we’ve got a valid git repository, and that’s the HEAD. You might’ve come across this before – HEAD just means “what is your repository pointing to right now?”. It’s a text file and it’s either got a reference in (the normal state of a repository) or just a plain commit hash – this is what’s referred to as a “detache...

First seen: 2025-07-16 21:12

Last seen: 2025-07-17 18:16