/Git

Modern Git Commands And Features You Should Be Using

- Martin Heinz tl;dr: “Most people only ever touch the most basic of commands, such as add, commit, push or pull, like it's still 2005. Git however, introduced many features since then, and using them can make your life so much easier, so let's explore some of the recently added, modern git commands, that you should know about.” Martin presents Switch, Restore, Sparse Checkout, Worktree and Bisect. 

featured in #496


How I Use Git Worktrees

- Bill Mill tl;dr: “My favorite feature of git is one that not enough people know about: worktrees. Worktrees allow you to store branches of your repository in separate directories. This means you can switch branches by changing directory, instead of switching between branches in the same directory with git checkout or git switch. I've never seen anybody describe using worktrees quite the way I do, so I thought I'd write out how I like to work with them.”

featured in #495


Popular Git Config Options

- Julia Evans tl;dr: “I always wish that command line tools came with data about how popular their various options are, like: (1) “basically nobody uses this one”. (2) “80% of people use this, probably take a look”. (3) “this one has 6 possible values but people only really use these 2 in practice.” Julia asked about people’s favourite git config options and shares the responses.  

featured in #490


Git Tips And Tricks

- Scott Chacon tl;dr: “I’m going to write 3 short articles on some interesting Git things for intermediate to advanced Git users that you may not know, either because they just never came up or because they're pretty new and you've been using Git the same way for years. The topics are: (1) Oldies but goodies. (2) Some subtle new things. (3) Really large repositories and monorepos.”

featured in #489


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