SadServers
  • Scenarios
  • Labs
    All Labs Linux & Bash Web Servers Databases Data Processing Docker Kubernetes CI/CD Infrastructure as Code Tooling / Applications
  • Dashboard
  • Solutions
    For Individuals For Businesses
  • Ranking
  • Newsletter
  • Documentation
    FAQ Support Pro Accounts Pro+ Accounts Business Accounts Gift API CLI/TUI Privacy Troubleshooting Interviews
  • Blog
  • Pricing
  • Gift
    Gift Purchase Gift Redeem
  • About
Log In - Sign Up
  1. Labs
  2. Git
  3. Guide

Guide

Concepts and learning path

Troubleshooting

Failure modes and fixes

Cheatsheet

Commands to keep handy

Git guide

What Git does in production

Git stores project history as a graph of commits — snapshots with metadata (author, message, parent commits). Teams work on branches, merge via pull requests or direct merges, and sync through remotes (GitHub, GitLab, Bitbucket, or internal servers). Deploy pipelines pull tagged releases; configuration and infrastructure repos are versioned the same way as application code.

Core concepts

  • Repository — project folder plus .git metadata
  • Working tree — files you edit on disk
  • Staging area (index) — what the next commit will include
  • Commit — immutable snapshot referenced by a SHA
  • Branch — movable pointer to a commit (e.g. main)
  • Remote — named URL for fetch/push (usually origin)

Typical workflow

  1. Clone — git clone url copies repo and sets origin
  2. Branch — git checkout -b feature/x for isolated work
  3. Stage — git add selects changes for the next commit
  4. Commit — git commit records a snapshot locally
  5. Pull — git pull fetches and merges remote changes
  6. Push — git push uploads commits to the remote

The .git directory

All history lives under .git/ — objects (commits, trees, blobs), refs (branches, tags), config, and hooks. Deleting or corrupting this directory loses local history unless you can re-clone. Server-side backups and protected branches on the remote are your safety net.

Remotes and authentication

HTTPS remotes use username + token or password. SSH remotes use keys — see the SSH lab for key generation, ssh-agent, and known_hosts. Deploy keys and machine users are common on CI runners; never commit private keys into the repo.

Merge vs rebase

Merge combines branches with a merge commit — preserves exact history. Rebase replays commits on top of another branch — linear history but rewrites SHAs. Do not rebase commits already pushed to a shared branch unless the team agrees.

Tags and releases

Lightweight or annotated tags mark release points (v1.2.0). Pipelines trigger on tag push; production deploys often checkout a tag SHA, not a floating branch tip.

Global and local config

  • ~/.gitconfig — user.name, user.email, aliases
  • .git/config — remotes, branch tracking, repo-specific settings
  • git config --list --show-origin — see where each value comes from

Learning resources

  • Pro Git book — git-scm.com/book
  • Git reference — git-scm.com/docs
  • Learn Git Branching — learngitbranching.js.org (interactive visual tutorial)
  • Atlassian Git tutorial — atlassian.com/git/tutorials

Practice scenarios

Hands-on Git scenarios on live Linux VMs: git

Troubleshooting →
SadServersSadServers

Real-world Linux and DevOps scenarios for hands-on learning and technical assessment.

Uptime Robot ratio (30 days)
Product
  • Scenarios
  • For Individuals
  • For Businesses
  • Pricing
Resources
  • FAQ
  • Blog
  • Newsletter
Company
  • About Us
  • Support
  • Privacy Policy
  • Terms of Service
  • Contact
Connect With Us
info@sadservers.com

Made in Canada 🇨🇦
Updated: 2026-06-13 16:06 UTC – 2d2950a