Git is a widely-used software that enables version control, allowing you to track changes, restore previous versions, and create branches for your files and directories. It’s essential for project management, particularly for collaborative development. This guide will show you how to install and configure Git on an Ubuntu 18.04 server.
Requirements:
- A Linux server with Ubuntu 18.04 installed.
1. Installation:
First, update your server’s package repositories to ensure everything is up to date:
Once the update is complete, install Git with the following command:
sudo apt-get install git -y
After the installation, verify the installed Git version:
At the time of writing, the expected output should be:
Now that Git is installed and verified, proceed to the configuration step.
2. Git Configuration:
After installing Git, it's important to configure it with your information. This allows Git to associate your commits with the correct details. You can configure Git using the git config
command. Set your username and email, which Git uses in every commit message:
git config --global user.name "your_username"
git config --global user.email "your_email"
To confirm that your information has been saved correctly, run:
The output should look something like this:
user.name=your_username
user.email=your_email
This information is stored in the Git configuration file, which can be manually edited using a text editor if needed:
The configuration file should display the following:
[user]
name = your_username
email = your_email
While Git offers many configuration options, setting your username and email is essential for proper usage. Skipping this step may result in warnings when using Git.