Git is a powerful version control system that is widely used in software development. It helps developers to collaborate on code, track changes, and manage versions of their projects. In this blog post, we will walk you through the process of installing and configuring Git on Rocky Linux 9.
Update the system
Before installing Git on Rocky Linux 9, it’s a good practice to update the system. This ensures that your system has the latest packages and security patches. To do this, open the terminal and type the following command:
sudo dnf update
BashYou will be prompted to enter your password. Once you enter your password, the system will update all packages to their latest version.
Install Git
After updating the system, it’s time to install Git. To do this, type the following command in the terminal:
sudo dnf install git
BashThis command will download and install Git along with its dependencies. Once the installation is complete, you can verify the installation by typing the following command:
git --version
BashThis command will display the version of Git installed on your system.
Configure Git
Now that Git is installed on your Rocky Linux 9 system, you need to configure it with your name and email address. This is important because every Git commit will include this information.
To set your name, type the following command in the terminal:
git config --global user.name "Your Name"
BashReplace “Your Name” with your actual name. To set your email address, type the following command in the terminal:
git config --global user.email "your_email@example.com"
BashReplace “your_email@example.com” with your actual email address.
You can also set some other options, such as your preferred text editor, by using the following command:
git config --global core.editor "nano"
BashReplace “nano” with your preferred text editor.
Generate SSH Key
If you plan to use Git with remote repositories, it’s a good practice to use SSH keys to authenticate with the server. To generate an SSH key, type the following command in the terminal:
ssh-keygen
BashYou will be prompted to enter a filename and a passphrase. You can accept the default filename and press Enter. For the passphrase, you can choose to enter a passphrase or leave it blank.
Once the SSH key is generated, you can display it in the terminal using the following command:
cat ~/.ssh/id_rsa.pub
BashCopy the entire key and add it to your Git server.
Conclusion
In this blog post, we have walked you through the process of installing and configuring Git on Rocky Linux 9. By following the steps outlined in this post, you can get started with Git on Rocky Linux 9 in no time.