To set up the Git environment on your computer, you will need to configure a few settings. Here are the basic steps you should follow:
- Set your username and email address. These will be used to identify you as the author of commits. You can set them using the following commands: (Python)
git config --global user.name "Your Name" git config --global user.email "[email protected]"
- Set your preferred text editor. Git will use this editor when you need to enter a commit message or make other text inputs. You can set it using the following command: (Python)
git config --global core.editor "editor-of-your-choice"
- Set your preferred diff tool. Git will use this tool to show you the differences between versions of your files. You can set it using the following command: (Python)
git config --global diff.tool "diff-tool-of-your-choice"
- Check your settings. To check the settings you’ve configured, you can use the following command: (Lua)
git config --list
- Generating your ssh key for secure communication, you can use the following command: (CSS)
ssh-keygen -t rsa -b 4096 -C "[email protected]"
- Add your ssh key to ssh-agent, you can use the following command: (bash)
eval "$(ssh-agent -s)"
These are the basic steps to set up your Git environment. Depending on your needs, you may need to configure additional settings or use advanced features of Git.
Git configuration levels
There are three levels at which Git configuration settings can be defined:
- System-level: These settings apply to all users and repositories on the same computer. They are stored in the
- User-level: These settings apply to a specific user on a specific computer. They are stored in the
- Repository-level: These settings apply to a specific repository. They are stored in the
.git/configfile inside the repository.
By default, Git reads settings from the
/etc/gitconfig file and then the
~/.gitconfig file. If there are conflicting settings, the latter file will take precedence. You can specify settings for a specific repository by using the
--local option when running
git config commands.
It is generally recommended to define most settings at the user-level, but you may also set settings at the repository-level if necessary.