Git

Git is a distributed version control system that tracks changes in source code during software development. It enables collaboration, maintains history, and manages different versions of code.

Core Concepts

Repository A project's complete history and all versions of files.

Commit A snapshot of changes with a descriptive message.

Branch An independent line of development.

Merge Combining changes from different branches.

Common Commands

bash
# Initialize repository
git init

# Stage changes
git add .

# Commit changes
git commit -m "Add new feature"

# Push to remote
git push origin main

# Pull latest changes
git pull

# Create branch
git checkout -b feature-branch

# Merge branch
git merge feature-branch

Best Practices

  • Write clear commit messages
  • Commit often, push regularly
  • Use branches for features
  • Review changes before committing
  • Keep commits focused and atomic

Learn More