Git init, add, commit, status, log, diff, gitignore, the staging area, and the three trees model.
40 cards · basic cards · AI-written, checked twice. Edit anything.
- What does `git init` do?
Show answer
Creates a new Git repository in the current directory
- Where is Git's configuration and history stored after running `git init`?
Show answer
In a hidden `.git` directory
- What is the difference between the working directory and the staging area?
Show answer
The working directory contains all current files, while the staging area contains only changes marked for the next commit
- Why use a staging area instead of committing changes directly?
Show answer
It allows you to choose which specific changes to include in each commit
- What does `git add <file>` do?
Show answer
Stages the specified file for the next commit
- How do you stage all changes in the current directory at once?
Show answer
Use `git add .` or `git add -A`
- What does `git commit` do?
Show answer
Creates a snapshot of the staged changes with an author, timestamp, and message
- What is the purpose of the -m flag in `git commit -m "message"`?
Show answer
Allows you to write the commit message inline without opening an editor
- What happens to the staging area after you run `git commit`?
Show answer
It is cleared, ready for the next set of changes
- How do you modify the last commit without creating a new one?
Show answer
Use `git commit --amend`
- What does `git status` show?
Show answer
The status of files in the working directory and staging area, indicating what is changed, staged, or untracked
- What are untracked files?
Show answer
Files in the working directory that Git has never seen before and has not been told to track
- What are modified files in Git?
Show answer
Files that exist in the repository but have been changed since the last commit
- What does `git log` display?
Show answer
A history of all commits in reverse chronological order (newest first)
- How do you view each commit on a single line in `git log`?
Show answer
Use `git log --oneline`