Introduction to Git

1/9/2025

Introduction to Git

Git is a distributed version control system that tracks changes in any set of files.

Why Git?

  • Track changes: See what changed and when
  • Collaboration: Work with others on the same codebase
  • Branching: Work on features independently
  • Backup: Never lose your work

Installation

bash
# Check if installed
git --version

# Configure user
git config --global user.name "Your Name"
git config --global user.email "[email protected]"

Basic Commands

bash
# Initialize a repository
git init

# Clone a repository
git clone https://github.com/user/repo.git

# Check status
git status

# Add files to staging
git add filename.txt
git add .

# Commit changes
git commit -m "Your commit message"

# View history
git log
git log --oneline

The Three States

  1. Working Directory: Your local files
  2. Staging Area: Files ready to commit
  3. Repository: Committed snapshots