What is Git?
A distributed version control system - every developer has a full copy of the repo on their machine - GitHub/GitLab is the remote host for the source of truth copy
What is a repository (repo)?
A project folder tracked by Git - contains all files - folders - and the full history of every change ever made
What does distributed mean in Git?
Every developer has the complete repo and history locally - not dependent on a central server to work
What are the three states of a file in Git?
What is the working directory?
Your local files on disk - what you’re actively editing - Git tracks changes against the last commit
What is the staging area?
A holding zone for changes you’ve marked as ready to commit - you choose what goes in with git add
What does git init do?
Initializes a new Git repo in the current directory - creates a hidden .git folder that tracks everything
What does git clone do?
Downloads a full copy of a remote repo to your local machine - includes all history and branches
What does git status do?
Shows the current state of your working directory and staging area - which files are modified - staged - or untracked
What does git add do?
Moves file changes from working directory to the staging area - git add . stages everything - git add <file> stages one file</file>
What does git commit do?
Takes a snapshot of everything in the staging area and saves it to the repo history with a message
What does git push do?
Sends your local commits to the remote repo (GitHub) - git push origin <branch-name></branch-name>
What does git pull do?
Downloads and merges the latest changes from the remote repo into your local branch
What does git log –oneline do?
Shows the commit history in a compact format - one line per commit with hash and message
What is .gitignore?
A file that tells Git which files and folders to never track - like node_modules - __pycache__ - .env - *.zip
Why do you gitignore node_modules?
It contains thousands of dependency files that can be regenerated with npm install - bloats the repo and slows everything down
Why do you gitignore .env files?
They contain environment secrets like API keys - database URLs - credentials - never commit secrets to a repo
What is a commit hash?
A unique SHA identifier for each commit - like a fingerprint - example: a1b2c3d - used to reference specific commits
What is a remote?
A version of your repo hosted somewhere else - usually GitHub - the default remote is called origin
What does origin mean in Git?
The default name for your remote repository - when you clone a repo the source automatically gets named origin
What is the difference between git add and git commit?
git add stages changes (marks them ready) - git commit saves the staged changes as a permanent snapshot
What is an untracked file?
A new file Git has never seen before - shows up in git status until you git add it
What is a modified file?
A tracked file that has changes since the last commit - needs to be staged with git add before committing
What is the basic Git workflow for a single change?
1.Edit file
2. git add <file>
3. git commit -m "message"
4. git push origin <branch-name></branch-name></file>