Git is a tool that helps you keep track of changes in your project and lets many people work on it together without confusion.
Think of it like the “Google Docs for code”:
- On Google Docs, you can see who changed what, go back to old versions, and many people can edit at the same time.
- Git does the same thing for programming projects.
With Git, you can:
- Save snapshots of your project (called commits)
- Go back to an earlier version if something breaks
- Work on your own ideas (branches) without disturbing the main project
- Merge your work with your teammates safely
Git works for small projects (your own code) as well as big projects (teams, companies, open source on GitHub).
Key Features of Git
- Track changes → See what changed, who changed it, and when.
- Branching & Merging → Work on new ideas without disturbing main code.
- Distributed → No single point of failure, everyone has full history.
- Rollback anytime → Go back to previous working versions.
- Collaboration → Multiple people can work together smoothly.
Key Concepts in Git
- Repository (Repo)
- A repository is like a folder where Git stores your project files plus the full history of changes.
- It can be:
- Local Repository → on your computer.
- Remote Repository → on a server (e.g., GitHub, GitLab).
- Commit
- A commit is like taking a snapshot (photo) of your project at a certain point in time.
- Each commit has a unique ID, and you can go back to any commit later.
- Branch
- A branch is like creating a separate copy of your project to try new things without disturbing the main version.
- Default branch = main (or master).
- Merge
- Merging means combining changes from one branch into another.
- Used when you finish a feature and want to add it to the main project.
- Clone
- Cloning means making a copy of a remote repository (from GitHub, GitLab, etc.) onto your computer.
- Push & Pull
- Push → Send your commits from your local repo → remote repo (e.g., GitHub).
- Pull → Bring new changes from the remote repo → your local repo.