Git 🧩 1c – Initial Git Configuration
1c. Initial Git Configuration (Essential Post-Installation)
After installing Git, you should configure your user name and email address. This information is embedded in every commit you make, identifying you as the author.
- Set your user name
git config --global user.name "Your Name"- Replace
"Your Name"with your actual name. This should be the name you want to appear in your commits.
- Replace
- Set your email address
git config --global user.email "your.email@example.com"- Replace
"your.email@example.com"with the email address you want associated with your Git commits. This email is often linked to your GitHub/GitLab/Bitbucket account.
- Replace
- Configure Text Editor
You can set up a default text editor for commit messages.
For VS Code:
git config --global core.editor "code --wait"
For Sublime Text:
git config --global core.editor "subl -n -w"
For Vim:
git config --global core.editor "vim"
- Configure Aliases
Create shortcuts for frequently used Git commands to increase efficiency.
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.ci commit
git config --global alias.st status
Now, you can use git co instead of git checkout, git br for branches, and so on.
- Enable Auto-Correct
Git can help correct typos in commands. This setting will suggest the correct command if you make a small typo.
git config --global help.autocorrect 1
- Set Default Branch Name
Starting with Git 2.28, you can set the default branch name to something other than master.
git config --global init.defaultBranch main
Or for any other preferred branch name:
git config --global init.defaultBranch "development"
- Configure SSH Key
Using an SSH key can simplify authentication when pushing and pulling from remote repositories.
Generate SSH Key:
ssh-keygen -t rsa -b 4096 -C "your.email@example.com"
Follow the prompts to save the key (usually ~/.ssh/id_rsa).
Add SSH Key to SSH Agent:
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
Copy the SSH public key and add it to your GitHub/GitLab account.
- Verify your configuration
- To see all your global Git configurations, run:
git config --global --list - You should see your
user.nameanduser.emaillisted.
- To see all your global Git configurations, run: