A Git commit, represented by a single building block in my Git mental model, is a frozen moment in time for your project (sometimes referred to as a snapshot). Along with this snapshot Git stores metadata about the commit (e.g. the author of the commit). Each commit has a unique identifier called the commit hash (a.k.a. SHA), a 40 character long alphanumeric string that is often abbreviated to just the first seven characters (e.g. “2b3a38b”).
These are the rules I follow when writing Git commit messages. I’ve found these serve me well and are compatible with most projects I work on (if a project has a specific set of rules for writing Git commit messages, those would override any rules I’ve outlined here).
When visualizing Git branches, I find it easier to think of them as stacks of building blocks rather than the traditional Directed Acyclic Graph (DAG) visualizations.
One of the things that made me much better at Git was making my current branch (and whether or not I have any changed files) always visible. By default zsh includes everything you need to do this, you just need to configure it.
I recently setup a new MacBook as my primary machine and I made these notes in the hope they will streamline the process for me in the future.
When using Git version 2.27.0 or higher running the command ‘git pull’ will display, “warning: Pulling without specifying how to reconcile divergent branches is discouraged. You can squelch this message by running one of the following commands sometime before your next pull”.
I use Git in both my personal and professional life. Depending on the context, I want to use different contact information. This is how I set this up on my machine.
In Git 2.28 you can change the default branch name from ‘master’ to whatever you want (the name ‘main’ seems to be a popular choice). This is the command to run to add this to your configuration.
There are lots of ways to write variable names when programming. This is the list of ones I find myself using.