/Git

My Favourite Git Commit

- David Thompson tl;dr: “I like Git commit messages. Used well, I think they’re one of the most powerful tools available to document a codebase over its lifetime. I’d like to illustrate that by showing you my favourite ever Git commit. This commit is from my time at the Government Digital Service, working on GOV.UK. It has the rather unassuming name of “Convert template to US-ASCII to fix error.””

featured in #486


Dealing With Diverged Git Branches

- Julia Evans tl;dr: "One of the most common problems I see folks struggling with in Git is when a local branch (like "main") and a remote branch (maybe also called "main") have diverged. There are two things that make this hard: (1) If you’re not used to interpreting git’s error messages, it’s nontrivial to realize that your main has diverged from the remote. (2) There's no single clear way to handle it - it depends on the situation and your git workflow." Julia discusses what to do.

featured in #485


Inside .git

- Julia Evans tl;dr: Julia provides a short explanation of each part of your .git directory helps develop your mental model and better understanding: (1) How merges and rebases work and how they can go wrong. (2) How exactly your colleagues are using git, and what guidelines you should be following to work with them successfully. (3) How pushing / pulling code from other repositories works. (4) how to handle merge conflicts. 

featured in #484


Do We Think Of Git Commits As Diffs, Snapshots, And/ Or Histories?

- Julia Evans tl;dr: "I’ve been extremely slowly trying to figure how to explain every core concept in Git (commits! branches! remotes! the staging area!) and commits have been surprisingly tricky. Understanding how git commits are implemented feels pretty straightforward to me, but it’s been much harder to figure out how other people think about commits. So like I’ve been doing a lot recently, I went on Mastodon and started asking some questions."

featured in #478


Mounting Git Commits As Folders

- Julia Evans tl;dr: "The main reason I wanted to make this was to give folks some intuition for how git works under the hood. After all, git commits really are very similar to folders – every Git commit contains a directory listing of the files in it, and that directory can have subdirectories, etc... It’s just that git commits aren’t actually implemented as folders to save disk space. So in git-commit-folders, every commit is actually a folder, and if you want to explore your old commits, you can do it just by exploring the filesystem!"

featured in #471


Git Branches: Intuition & Reality

- Julia Evans tl;dr: Julia discusses an intuitive mental model that many people have, how git actually represents branches internally i.e. branches are a pointer to a commit, how the “intuitive model” and the real way it works are actually pretty closely related and some limits of the intuitive model and why it might cause problems. 

featured in #468


Git Notes: Git's Coolest, Most Unloved­ Feature

- Tyler Cipriani tl;dr: "A common use of git notes is tacking metadata onto commits. Once a commit cements itself in git’s history - that’s it. It’s impossible to amend a commit message buried deep in a repo’s log. But git notes enable you to amend new information about old commits in a special namespace. And they’re capable of so much more. Notes stow metadata about anything tracked by git - any object: commits, blobs, and trees. All without futzing with the object itself."

featured in #464


Confusing Git Terminology

- Julia Evans tl;dr: "One of my biggest problems is that after almost 15 years of using git, I’ve become very used to git’s idiosyncrasies and it’s easy for me to forget what’s confusing about it." Julia asked folks "what git jargon do you find confusing? thinking of writing a blog post that explains some of git’s weirder terminology: “detached HEAD state”, “fast-forward”, “index/staging area/staged”, “ahead of ‘origin/main’ by 1 commit”, etc."

featured in #463


My Muscle-Memory Git Toolbox

- Arthur O’Dwyer tl;dr: "This post focuses on my basic muscle-memory git commands. There are at least two other major Git subtopics this post doesn’t mention at all: “branching discipline” (what is a release branch? what’s the difference between rebase and merge?) and “hygiene” (how big should a commit be? what does a good commit message look like?). That is — as usual for this blog — we’re talking tactics, not strategy."

featured in #462


Some Miscellaneous Git Facts

- Julia Evans tl;dr: “None of these things feel super surprising in retrospect, but I hadn’t thought about them clearly before. The facts are: (1) The “index”, “staging area” and “–cached” are all the same thing. (2) The stash is a bunch of commits. (3) Not all references are branches or tags. (4) Merge commits aren’t empty.” Julia discusses each in detail.

featured in #459