After creating a pushing a new branch to GitHub (or any remote), when I do “git pull” I often get an error that says “There is no tracking information for the current branch”. The Git config value “autoSetupRemote”, introduced in Git version 2.38, lets us avoid this entirely error.
gitconfig
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 Commit Message Editor
By default Vim is the editor used when writing a Git commit message. While I love Vim, it does work very differently than most other editors. A good option for those who are not comfortable with Vim, is to use a different editor. This is how to setup Git to use a different editor.
Improve Git Log
By default the output of ‘git log’ is not nearly as useful as it could be. By creating a new command ‘git lg’ that uses some of the options available to ‘git log’, we create a much more useful command.