Git Studio
The Interactive Guide to Version Control.
Git Challenges
Mastering Time Travel for Code
Git is a Distributed Version Control System. Think of it as a time machine for your project. Every time you save (commit), you create a checkpoint. You can travel back to any checkpoint, create parallel universes (branches), and merge them back together.
The "Three Trees" Architecture
Understanding these three zones is the key to mastering Git.
1. Working Directory
This is your actual folder with files. Changes here are "Unstaged". They are just files on your disk.
2. Staging Area
You `git add` files here. It's a "Draft" of your next commit. You can pick and choose what to include.
3. Repository
You `git commit` to move changes here. This is the permanent history database (.git folder).
How to Use the Builder
- For Beginners: Use the "Command Builder" tab. Instead of memorizing
git checkout -b, just click "Work with branches" → "Create new". - For Practice: Open the "Terminal" tab. We provide a safe, fake file system where you can run
git init,touch, and `commit` without messing up your computer. complete the challenges to level up! - For Visual Learners: Check the "Flow Visualizer" to see how branches split and merge back into the main timeline.
- For Setup: Use the ".gitignore Generator" to instantly create ignore files for Node.js, Python, or Mac.
- For Pros: Use the "Cheat Sheet" for quick reference to obscure commands.
Frequently Asked Questions
What is the difference between Git and GitHub?
Git is the software installed on your local computer that tracks file changes. GitHub is a cloud service (like Google Drive for code) where you upload your Git repositories to share with others.
How do I undo the last commit?
If you want to keep your file changes but remove the commit, use git reset --soft HEAD~1. If you want to destroy all changes and revert to the previous state, use git reset --hard HEAD~1. Be careful with hard resets!
What is a Merge Conflict?
A conflict occurs when two people change the exact same line of code in the same file. Git doesn't know which one to keep, so it pauses and asks you to manually edit the file to choose the correct version.
What is the difference between 'git pull' and 'git fetch'?
git fetch downloads the latest updates from the remote server but does not apply them to your files. git pull downloads the updates AND immediately merges them into your current branch. Pull = Fetch + Merge.
What is a Branch?
A branch is a parallel version of your project. It allows you to work on a new feature or fix a bug in isolation without affecting the main stable code. Once finished, you merge the branch back.
What does 'HEAD' mean in Git?
HEAD is a pointer that refers to the current commit you are viewing. Usually, it points to the tip of the branch you are currently on. A 'Detached HEAD' means you are viewing a past commit, not the tip of a branch.
What is the Staging Area (Index)?
The Staging Area is a middle ground between your working directory and the repository history. You 'add' files to the stage to prepare them for a commit. This lets you choose exactly which changes to include in the snapshot.
Explain Merge vs Rebase.
Merge combines history, creating a new 'merge commit' that ties two branches together (preserving the fact that they split). Rebase rewrites history, moving your entire branch to the tip of the main branch as if you started working from there today (creating a linear history).
How do I ignore files?
Create a file named .gitignore in your project root. List file patterns (like *.log or /node_modules) inside it. Git will stop tracking these files.
What is a Pull Request (PR)?
A Pull Request is not a Git command, but a GitHub/GitLab feature. It is a request to merge your branch into the main branch, usually allowing team members to review the code before it is accepted.