When setting up Git for the first time, there are a few steps you’ll need to follow to configure your environment and ensure that Git can properly identify you as the author of your commits. Here’s an overview of the process:
- Install Git: You can download the latest version of Git for your operating system from the official website (https://git-scm.com/downloads). Once you’ve downloaded the installer, follow the prompts to install Git on your computer.
- Configure your user name and email: To identify yourself as the author of your commits, you’ll need to set your user name and email address in Git. You can do this by running the following commands in the command line:
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
This configures git with user name and email and this configuration is global, it means it will be applicable to all the repositories on your computer.
3. Set up an SSH key: If you plan on working with remote repositories (e.g. those hosted on GitHub), you’ll need to set up an SSH key to authenticate with the server. You can generate a new key by running the following command:
ssh-keygen -t rsa -b 4096 -C "your.email@example.com"
This will create a new SSH key with the specified email as a label.
4. Add the SSH key to your remote server: Once you’ve generated your key, you’ll need to add it to your remote server (e.g. GitHub) so that you can authenticate with it. You can do this by copying the key to your clipboard (using the command cat ~/.ssh/id_rsa.pub
), then adding it to your remote server in your account setting page.
5. Testing the connection: You can test the connection of SSH key by running ssh -T git@github.com
.
After you have completed these steps, you should be set up and ready to start using Git.