Git Tutorial
Git is a free and open-source distributed version control system (VCS) designed to handle everything from small to very large projects with speed and efficiency. Its primary purpose is to manage and track changes in files, particularly source code, over time.
It is our go-to tool for source code versioning. This tutorial will guide you on how to install and configure it on your machine.
Pre-Requisites
We follow two key general conventions with configuration:
- A GitHub account created with (or associated to) the company's domain
- SSH configuration (refer to this tutorial)
We use only SSH to clone and contribute to remote repositories.
Setup
Step 1: Installation
Open your terminal and run the following command to ensure your local package index is up-to-date:
sudo apt update
After the update is complete, install Git using the apt package manager:
sudo apt install git
Alternatively, you can install git-all to include additional Git-related tools:
sudo apt install git-all
To confirm that Git has been installed successfully, check its version:
git --version
This command should output the installed Git version if it all went correctly.
Step 2: Configuration
Commit Identity
Set your global username and email, which will be associated with your commits:
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
Note: Make sure you use the company domain email assigned to you.
SSH Config
Now you should configure SSH on your GitHub account. It tells GitHub that your machine is allowed to access your own account.
This step is required for organization repository access.
Copy your public SSH key from the output of this command:
cat ~/.ssh/id_ed25519.pub
Navigate to GitHub → Profile picture (top right) → Settings → Access → SSH and GPG keys → New SSH key.
Paste the contents of ~/.ssh/id_ed25519.pub, give it a title then save.
You may now test connectivity via:
ssh -T git@github.com
Note: For the first time, answer "yes" to add GitHub's host key. It is only a single-time prompt.
If the connection was accepted, it should output the following message (or similar):
Hi USERNAME! You've successfully authenticated, but GitHub does not provide shell access.
Step 3: Verification
Once your SSH key is registered and your connection test succeeds, try cloning a repository over SSH to verify end-to-end:
git clone git@github.com:OWNER/REPOSITORY.git
cd REPOSITORY
git remote -v
You should see something like:
origin git@github.com:OWNER/REPOSITORY.git (fetch)
origin git@github.com:OWNER/REPOSITORY.git (push)
Note: You can test it on TiniTec's repositories. For example:
git clone git@github.com:tinitec/tinitec-wiki.git
You may now try making a small change and push to see if it works:
git checkout -b xyz
echo "# test" >> README.md
git updated README.md
git commit -m "Test SSH push"
git push -u origin xyz
Notes:
- You can clone a known public repo (e.g. a GitHub demo) or a personal one to test that Git works over SSH.
- You may ask for privileges for the private GitHub organization and privileges for specific projects.
Troubleshooting
- Permission denied (publickey) → ensure the public key is pasted into GitHub, run
ssh-add ~/.ssh/id_ed25519, and test withssh -vT git@github.comfor debug output. - Agent not running →
eval "$(ssh-agent -s)"thenssh-add. - Firewall blocking port 22 → try
ssh -T -p 443 git@ssh.github.com. - Wrong remote URL (e.g., HTTPS instead of SSH) → run
git remote -vand ensure it points togit@github.com:OWNER/REPO.git. Update withgit remote set-url origin git@github.com:OWNER/REPO.git.
For more information, refer to the official Git reference, the GitHub Training Kit for manuals and cheatsheets on Git and GitHub, as well as our contribution guide.