Git is a distributed version control system that tracks changes in source code during software development. It enables multiple developers to work on the same codebase without overwriting each other's work.
Why Git Matters
Without version control:
- You'd have folders named "final," "final_v2," "final_ACTUALLY_final"
- Collaboration would be chaos
- Reverting mistakes would mean restoring backups
- You couldn't see who changed what or why
Core Concepts
Repository (Repo)
A project folder tracked by Git. Contains your code and its entire history.
Commit
A snapshot of your code at a point in time. Each commit has a message describing the changes.
Branch
A parallel version of your code. Work on features without affecting the main codebase:
main ────●────●────●────●
\
feature-x ●────●
Merge
Combine changes from one branch into another. Git automatically handles most conflicts.
Pull Request (PR)
A request to merge your branch into the main branch. Enables code review before changes go live.
Common Git Workflow
- Pull latest changes from the remote repository
- Create a branch for your feature
- Make changes and commit them
- Push your branch to the remote
- Open a pull request for review
- Merge after approval
Git Hosting Platforms
- GitHub: Most popular, owned by Microsoft
- GitLab: Self-hostable, built-in CI/CD
- Bitbucket: Integrates with Atlassian tools
Git vs. GitHub
Git is the tool. GitHub (and GitLab, Bitbucket) are platforms that host Git repositories and add collaboration features like pull requests, issues, and project management.