February 9, 2025
O. Wolfson
Version control is a system that records changes to files over time, allowing multiple people to collaborate efficiently, track modifications, and revert to previous versions when needed. It is crucial in production environments where maintaining a reliable history of changes ensures stability, accountability, and the ability to fix issues quickly.
Without version control, managing multiple versions of a project can be chaotic, leading to lost progress, overwritten work, and difficulty in tracking changes. Version control systems (VCS) prevent these issues by maintaining a structured history of changes.
While Git is a distributed version control system, platforms like GitHub, GitLab, and Bitbucket provide hosting services and collaboration features built around Git. Here’s how they differ:
Version control systems fall into two categories:
Git’s distributed nature provides several advantages:
To start using Git, install it on your operating system.
Download the installer from git-scm.com.
Run the installer and follow the setup instructions.
Verify the installation:
shgit --version
Install Git using Homebrew:
shbrew install git
Verify the installation:
shgit --version
Install Git using the package manager:
shsudo apt install git # Debian-based systems
sudo dnf install git # Fedora-based systems
Verify the installation:
shgit --version
After installation, configure Git with your user information:
shgit config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
To check the current configuration:
shgit config --list
Install Git following the instructions above.
Set up your global Git configuration with your name and email.
Generate SSH keys for GitHub authentication:
SSH keys are cryptographic keys that allow secure authentication with remote servers like GitHub without using a password. Generate an SSH key using the following command:
shssh-keygen -t ed25519 -C "your.email@example.com"
Enter
to use the default location, which is ~/.ssh/id_ed25519
.id_ed25519
(private key, never share this)id_ed25519.pub
(public key, used for authentication)Copy the public key:
shcat ~/.ssh/id_ed25519.pub
This command displays the public key, which you need to add to GitHub.
Add the key to GitHub:
Test the connection:
shssh -T git@github.com
You are now ready to start using Git for version control!
If successful, you’ll see a message like:
textHi username! You've successfully authenticated, but GitHub does not provide shell access.
This means the connection is working, but GitHub does not allow direct shell access like a traditional server. You can now securely push and pull code from GitHub using SSH authentication.