As you embark on this mystical Git journey, you’ve successfully summoned Git into your service. But what’s next? It’s time to personalize your Git environment, tailoring it to your preferences.
Setting up Git up for general usage
The art of Git customization begins with the following crucial steps:
- Setting up your identity
- Username: Provide a name that identifies you within the Git realm.
- Email Address: Register your email address to receive notifications and updates.
- Setting up default editor: Choose the text editor you prefer to use for composing your commits and editing files.
- Setting up default branch name: Specify the default branch name that Git should use when creating new repositories.
Setting up your identity
In the mystical world of version control, your identity is essential. Just as you introduce yourself in a new land, Git also needs to know who you are. Git uses this information to identify your commits, which are snapshots of your code’s progress.
Ah, commits? You haven’t yet ventured into their depths. But fear not, for we shall explore them later. For now, remember that Git merely requires two keys - your username and email address.
How to set up username and email address?
- Open your terminal, regardless of your operating system.
-
Execute the following commands:
git config --global user.name "Your Name"
git config --global user.email "youremail@example.com"
-
Verify your identity settings by running:
git config --list
Good to know: By using the--global
flag you ensure that Git remembers your identity across all projects. If you need to set different identities for specific projects, simply omit the--global
flag when configuring Git within that project’s directory.
Choosing Your Editorial Companion
With your identity established, it’s time to inform Git of your preferred text editor. Git defaults to the system’s default editor, but you can customize this choice to enhance your workflow.
How to set up default editor?
- Open your terminal.
-
Execute the following command:
git config --global core.editor nameofyoureditor
For example,
git config --global core.editor atom
Note: Windows users need to provide the full path to their editor’s executable file (.exe). -
Verify your editor settings by running:
git config --list
Setting up default branch name
When you create a new Git repository, Git automatically creates a default branch named master
. However, you can customize this default name to your preference.
With your identity and trusty text editor aligned, it’s time to declare the default branch name. Failing to do so would lead Git to create a master branch when you create (initialize) a new Git repository.
So now Git knows about you and your favorite text editor.
How to set up default branch name?
- Open your terminal.
-
Execute the following command:
git config --global init.defaultBranch main
Note: I recommend usingmain
as your default branch name. -
Verify your default branch settings by running:
git config --list
Congratulations! You’ve successfully personalized your Git environment, making it more aligned with your preferences and workflow. Git is now attuned to your essence and ready to serve you efficiently.
Course completed
Have an issue? Please provide specific feedback by reporting an issue.