Install & Configure Git on CentOS 7
Below are the steps to install and configure the Git version control tool in CentOS7:
- Install Git using yum: Execute the following command in the terminal to install Git.
sudo yum install git
- Configure Git: After installing Git, it is necessary to set up user information, including username and email. Execute the following command in the terminal.
git config --global user.name "Your Name"
git config --global user.email "youremail@example.com"
- Generate SSH keys: If you need to pull and push code using the SSH protocol, you can generate SSH keys. Run the following command to generate SSH keys.
ssh-keygen -t rsa -b 4096 -C "youremail@example.com"
Simply press the Enter key repeatedly as per the prompts to generate the SSH key.
- Add SSH key to GitHub or other code hosting service: Copy the generated SSH key content and paste it into the SSH key settings on GitHub or other code hosting service.
- Verify configuration: You can check the Git configuration information using the following command.
git config --list
At this point, you have successfully installed and configured the Git version control tool in CentOS7. Now you can start using Git for code version management.