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.
Git
Git branch list without asterisk
By default “git branch” will list all of your local branches with an asterisk in front of the current branch. We can remove the asterisk and list only the branch names by adding the “format” parameter.
Git warning: Pulling without specifying how to reconcile divergent branches is discouraged
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”.
Git Work Email
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.
Git Change Default Branch to Main
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.
Git alias to open Jira URL
As a developer, I spend a lot of time going back and forth between the command line and Jira tickets. I realized that since I always include the Jira ticket identifier (e.g. `sf-123`) in the branch name (in a reliable position), I could write a git alias to open the corresponding URL. This is how I implemented this behavior.
Git Preview Changes in Commit Message
You can set Git to preview all of the changes in your commit when you write your commit message. I find this to be a big help in writing my commits (and reminds me to keep the changes in my commits small).
git switch
Git version 2.23.0 is introduced a new command ‘git switch’. This command does a subset of what ‘git checkout’ does (because ‘git checkout’ does so many different things).
git restore
Git version 2.23.0 is introduced a new command ‘git switch’. This command does a subset of what ‘git checkout’ does (because ‘git checkout’ does so many different things).
Git Diff Ignore Mode Changes
When the permissions on a file change in a commit, Git will include this in the diff. Git refers to this as a mode change. When I’m looking at a “git diff” (or specifically a “git diff –name-only” where I’m looking for a list of files that have been changed), I often want to ignore mode changes (a.k.a. permission changes). By adding “-G.” to the command, mode changes will be ignored.