📦
Version Control

Git

Distributed version control system

🐧 Linux🍎 Mac🪟 Windows📋 Quick reference →
Reviewed: Tested on: Kubernetes 1.29 · Terraform 1.8 · Ubuntu 22.04

What is this?

Git tracks every change to your code so you can undo mistakes and collaborate with others.

📁

Config files for Git

Where to create or edit the main configuration — paths below match the setup steps.

  • ~/.gitconfig

    Location: User home

    Global user.name, user.email, aliases

  • .git/config

    Location: Inside each repository

    Repo remotes and branch settings

📥

Step 01

Install Git

(01)Install Git

Linux
1# Ubuntu / Debian
2sudo apt-get update && sudo apt-get install -y git
3
4# RHEL / Fedora
5sudo dnf install -y git

(02)Configure Git

Linux
1git config --global user.name "Your Name"
2git config --global user.email "you@example.com"
3git config --global init.defaultBranch main
4git config --global --list

Step 02

Verify Installation

(01)Check Version

Linux
1git --version

Step 03

Manage Git

(01)Repository Basics

Linux
1git init
2git clone https://github.com/user/repo.git
3git status
4git add .
5git commit -m "Initial commit"
6git push origin main

(02)Branching

Linux
1git branch
2git checkout -b feature/new-feature
3git merge feature/new-feature
4git branch -d feature/new-feature
5git push origin --delete feature/new-feature

(03)Remote & Sync

Linux
1git remote -v
2git fetch origin
3git pull origin main
4git push origin main
5git log --oneline -10
🔧

Step 04

Common Problems

#1Permission denied (push to GitHub)

Linux
1# Use SSH instead of HTTPS, or set credential helper
2git remote -v
3git remote set-url origin git@github.com:user/repo.git
4ssh -T git@github.com