---
tags:
- devops
- l1
- flashcard-deck
- git
---
<!-- wiki:breadcrumb:start -->
[Portal](../../../../library/portal/index.md) | **Level:** [L1: Foundations](../../../../library/portal/levels.md) | **Topics:** [Git](../../../../library/portal/topics.md) | **Domain:** DevOps & Tooling
<!-- wiki:breadcrumb:end -->

id	category	difficulty	tags	question	answer	source_path
git/066a0fab0d2c	git	medium	git, log	How can you see which changes have done before committing them?	`git diff` shows unstaged changes. `git diff --staged` (or `--cached`) shows what's staged for the next commit. Both let you review before committing.	projects/knowledge/interview/git/007-how-can-you-see-which-changes-have-done-before-com.txt
git/0b381164439f	git	medium	git, log	If git status has to run diff on all the files in the HEAD commit to those in staging area/index and another one on staging area/index and working directory, how is it fairly fast?	One reason is about the structure of the index, commits, etc.\n\n- Every file in a commit is stored in tree object\n- The index is then a flattened structure of tree objects\n- All files in the index have pre-computed hashes\n- The diff operation then, is comparing the hashes\n\nAnother reason is caching\n\n- Index caches information on working directory\n- When Git has the information for certain file cached, there is no need to look at the working directory file	projects/knowledge/interview/git/037-if-git-status-has-to-run-diff-on-all-the-files-in-.txt
git/0b8e18e8262d	git	medium	git, branching	Explain the purpose of the .gitignore file.	The .gitignore file tells Git which files and directories it should not track or include in version control. It's useful for excluding build artifacts, log files, and other things that shouldn't be in the repository.	projects/knowledge/interview/git/048-explain-the-purpose-of-the-gitignore-file-explanat.txt
git/0bc89282d5c1	git	medium	git, stash	Explain the Git three-stage workflow (working directory, staging area, and repository)	Git has three stages for tracking changes:\n\n1. **Working Directory**: Your local filesystem where you edit files. Changes here are 'modified' but not yet tracked\n2. **Staging Area (Index)**: A holding area where you selectively prepare changes for commit using `git add`. Lets you group related changes into logical commits\n3. **Repository (.git)**: The permanent record. `git commit` saves staged changes as a new snapshot with a message\n\nFlow: Edit files -> `git add` (stage) -> `git commit` (save to history). This three-stage design lets you craft clean, intentional commits rather than saving everything at once.	projects/knowledge/interview/git/054-explain-the-git-three-stage-workflow-working-direc.txt
git/0d962c9d1b44	git	easy	git, remote	What does git remote -v show?	`git remote -v` shows the fetch and push URLs for each configured remote repository. Most repos have one remote named 'origin', but you can add more (e.g., 'upstream' for forked repos). Example output: `origin https://github.com/user/repo.git (fetch)`.	projects/knowledge/interview/git/102-git-remote-v.txt
git/0f04400906ad	git	medium	git, branching	How do you know if a certain directory is a git repository?	Check if there is a `.git` directory in the project root. Run `ls -la .git` or `git rev-parse --is-inside-work-tree` which returns 'true' if you're inside a git repo. \nGotcha: bare repositories (used as central hubs) have no working tree — use `git rev-parse --is-bare-repository` instead.	projects/knowledge/interview/git/002-how-do-you-know-if-a-certain-directory-is-a-git-re.txt
git/0f1793fd5426	git	medium	git, branching	You have files in your repository you don't want Git to ever track them. What should you be doing to avoid ever tracking them?	Add file patterns to `.gitignore` to prevent Git from tracking them. Example patterns: `*.log`, `node_modules/`, `.env`. Files already tracked are not affected — use `git rm --cached <file>` to untrack them first. \nGotcha: `.gitignore` only works for untracked files, not files already in the index.	projects/knowledge/interview/git/010-you-have-files-in-your-repository-you-dont-want-gi.txt
git/0f761caad5b2	git	easy	git, branching	What is a Git branch?	A branch is a lightweight movable pointer to a commit, representing an independent line of development. Creating a branch is nearly instantaneous because Git just creates a 41-byte file (the SHA reference). Common branches: main/master (production), feature/* (new work), hotfix/* (urgent fixes). Use `git branch -a` to list all.	projects/knowledge/interview/git/070-what-is-git-branch.txt
git/1318e582d1bc	git	medium	git, remote	What is the difference between git pull and git fetch?	git fetch downloads new commits from a remote repository to your local repo (but doesn't merge them), whereas git pull fetches and immediately merges (or rebases) them into your current branch.	projects/knowledge/interview/git/068-git-pull-vs-git-fetch.txt
git/146e21b2bd58	git	medium	git, stash	What is a "Git bundle"?	A Git bundle is a single file containing repository data (commits, branches, tags) that can be transferred offline. Create with `git bundle create repo.bundle --all`. Useful for sneakernet transfers or air-gapped environments. Import with `git clone repo.bundle` or `git fetch repo.bundle`.	projects/knowledge/interview/git/090-git-bundle.txt
git/178c967a04a1	git	easy	git, branching	What is the .git directory? What can you find there?	The `.git` folder contains all the information that is necessary for your project in version control and all the information about commits, remote repository address, etc. All of them are present in this folder. It also contains a log that stores your commit history so that you can roll back to history.\n\nThis info copied from [https://stackoverflow.com/questions/29217859/what-is-the-git-folder](https://stackoverflow.com/questions/29217859/what-is-the-git-folder)	projects/knowledge/interview/git/025-what-is-the-git-directory-what-can-you-find-there.txt
git/17effa1ab701	git	medium	git, log	Which one is faster? git diff-index HEAD or git diff HEAD	`git diff-index` is faster but to be fair, it's because it does less. `git diff index` won't look at the content,\nonly metadata like timestamps.	projects/knowledge/interview/git/034-which-one-is-faster-git-diff-index-head-or-git-dif.txt
git/1b9fd0a54601	git	easy	git, branching	What is the "HEAD" in Git?	HEAD is a reference (pointer) to the latest commit on the currently checked-out branch. It's stored in `.git/HEAD` and usually contains a symbolic reference like `ref: refs/heads/main`. Use `HEAD~1` for the parent commit, `HEAD~3` for three commits back. Detached HEAD means HEAD points directly to a commit, not a branch.	projects/knowledge/interview/git/080-what-is-head.txt
git/21d2c2a0d838	git	medium	git, log	What is git tag -a used for?	`git tag -a v1.0 -m 'Release 1.0'` creates an annotated tag with a message, tagger name, date, and optional GPG signature. Unlike lightweight tags (`git tag v1.0`), annotated tags are full Git objects stored in the database. Use annotated tags for releases; they show up in `git describe` and can be verified.	projects/knowledge/interview/git/098-git-tag.txt
git/23f3e8879b9d	git	easy	git, log	How do you check the status of your Git repository?	`git status` shows which files are modified, staged, or untracked in your working directory. Red means unstaged changes; green means staged and ready to commit. Use `git status -s` for a compact view: M=modified, A=added, ??=untracked. Add `-b` to also show the branch name.	projects/knowledge/interview/git/067-check-repository-status.txt
git/26b06b217d3d	git	medium	git, rebase	In what situations are you using git rebase?	Suppose a team is working on a `feature` branch that is coming from the `main` branch of the repo. At a point, where the feature development is done, and finally we wish to merge the feature branch into the main branch without keeping the history of the commits made in the feature branch, a `git rebase` will be helpful.	projects/knowledge/interview/git/023-in-what-situations-are-you-using-git-rebase.txt
git/2817fffd0cb8	git	medium	git, merging	What is a merge conflict in Git?	A situation where two commits (usually from different branches) have changed the same lines in a file, requiring manual resolution before merging.	projects/knowledge/interview/git/072-what-is-merge-conflict.txt
git/28eb9d2395cf	git	medium	git, stash	You've created new files in your repository. How to make sure Git tracks them?	`git add FILES` stages files for the next commit. Use `git add .` for all changes in the current directory, or `git add -p` to interactively stage individual hunks within files. \nGotcha: `git add` only snapshots the file at that moment — further edits require another `git add`.	projects/knowledge/interview/git/009-youve-created-new-files-in-your-repository-how-to-.txt
git/2a994a4e8a2e	git	medium	git, rebase	What is git reset (in general)?	It moves the current branch pointer to a specified commit. For example, git reset --hard HEAD~1 will move HEAD back one commit and discard that commit's changes. (Different options: --soft, --mixed, --hard determine what happens to index and working tree).	projects/knowledge/interview/git/077-what-is-git-reset.txt
git/2f22452ceb8d	git	medium	git, merging	You have two branches - main and devel. How do you merge devel into main?	`git checkout main && git merge devel && git push origin main`. This creates a merge commit combining devel's changes into main. If there are conflicts, Git marks them in the files with `<<<<<<<`/`=======`/`>>>>>>>` markers — resolve, then `git add` and `git commit`. Use `--no-ff` to always create a merge commit for clearer history.	projects/knowledge/interview/git/017-you-have-two-branches-main-and-devel-how-do-you-me.txt
git/310ffe54bd85	git	medium	git, rebase	What is a Git rebase, and when might you use it?	Git rebase is like rewriting the history of your branch. It allows you to move your changes on top of another branch's changes, creating a cleaner and more straightforward history. It's used when you want a linear history without many merge commits.	projects/knowledge/interview/git/059-what-is-a-git-rebase-and-when-might-you-use-it-exp.txt
git/325587a7cd9c	git	easy	git, remote	What is the difference between git fetch and git pull?	`git fetch` downloads new commits and refs from the remote but does not modify your working directory. `git pull` does a fetch followed by a merge (or rebase with `--rebase`). \nBest practice: use `git fetch` then inspect with `git log origin/main..main` before merging to avoid surprises.	projects/knowledge/interview/git/071-fetch-vs-pull.txt
git/32d61a9f5b07	git	easy	git, remote	What is "origin" in Git?	'origin' is the default alias Git assigns to the remote repository you cloned from. It's just a shorthand — you can rename it with `git remote rename origin upstream`. View all remotes with `git remote -v`. You can add additional remotes: `git remote add upstream <url>` for fork workflows.	projects/knowledge/interview/git/072-origin-meaning.txt
git/344f46c183b9	git	easy	git, log	How does git diff function?	`git diff` shows line-by-line differences between your working directory and the staging area. Use `git diff --staged` (or `--cached`) to compare staged changes against the last commit. `git diff branch1..branch2` compares two branches. Add `--stat` for a summary of changed files and line counts.	projects/knowledge/interview/git/089-git-diff.txt
git/35f9550f1af7	git	medium	git, branching	What is a Git repository?	A Git repository is like a special folder that stores all the files, their history, and the changes made to them. It's where Git keeps track of your project.	projects/knowledge/interview/git/042-what-is-a-git-repository-explanation-in-the-world-.txt
git/369d41d82d9c	git	medium	git, remote	What is a Git pull request?	A pull request is a way to suggest changes from one branch (e.g., a feature branch) to another (e.g., the main branch). It's a request for someone to review and approve your changes.	projects/knowledge/interview/git/046-what-is-a-git-pull-request-explanation-think-of-a-.txt
git/37507def258c	git	medium	git, log	What is a Git commit message, and why is it important?	A Git commit message is a short description of the changes you made in a commit. It's essential because it helps you and your collaborators understand the purpose of the change, making it easier to review and track changes over time.	projects/knowledge/interview/git/053-what-is-a-git-commit-message-and-why-is-it-importa.txt
git/419315415ebe	git	easy	git, stash	How do you restore a file to its state in the last commit?	`git restore <file>` discards unstaged changes, reverting the file to the last committed version. Use `git restore --staged <file>` to unstage without discarding changes. \nGotcha: `git restore` permanently discards your working directory changes — there is no undo. Consider `git stash` first if unsure.	projects/knowledge/interview/git/099-git-restore.txt
git/458dd4b99b27	git	medium	git, branching	What is a branch in Git?	A branch is like a separate path for your project's development. You can work on new features or fixes in a branch without affecting the main project until you decide to merge the changes.	projects/knowledge/interview/git/044-what-is-a-branch-in-git-explanation-in-the-harry-p.txt
git/4631d37cc5b1	git	easy	git, remote	What is git clone used for?	`git clone <url>` copies a remote repository to your local machine, including all branches, tags, and commit history. \nExample: `git clone https://github.com/user/repo.git`. Use `--depth 1` for a shallow clone (latest commit only) to save time on large repos. Add `--branch <name>` to clone a specific branch.	projects/knowledge/interview/git/073-what-is-git-clone.txt
git/47f39866a447	git	medium	git, remote	Explain the difference between Git pull and Git fetch.	Git pull is like getting updates from a remote repository and immediately merging them into your local branch. Git fetch is like fetching updates from a remote repository, but it doesn't automatically merge them. You can decide later when to merge the fetched changes.	projects/knowledge/interview/git/058-explain-the-difference-between-git-pull-and-git-fe.txt
git/49b13a61f2f1	git	easy	git, branching	What is Git and what is it used for?	Git is a distributed version control system used to track changes in source code during software development, enabling multiple developers to collaborate.	projects/knowledge/interview/git/063-what-is-git.txt
git/4a25e4b76ea6	git	easy	git, log	What does git commit -m "message" do?	`git commit -m "message"` creates a new commit containing all staged changes with the given message. The commit records a snapshot of the staging area, author, timestamp, and parent commit SHA. \nBest practice: write imperative messages like 'Add login validation' not 'Added login validation'. Use `-m` for one-liners only.	projects/knowledge/interview/git/066-what-does-git-commit-do.txt
git/4d993070271b	git	easy	git, log	What command shows the commit history?	`git log`. Useful flags: `--oneline` for compact output, `--graph` for branch topology, `-n 5` for last 5 commits, `--author=name` to filter by author.	projects/knowledge/interview/git/075-git-log.txt
git/4eb30a0271fa	git	easy	git, log	What is a "commit hash"?	A commit hash is a unique 40-character SHA-1 identifier computed from the commit's content, parent, author, and timestamp. You can reference commits by their first 7-8 characters (e.g., `git show abc1234`). \nGotcha: SHA-1 is deterministic — identical content always produces the same hash, enabling integrity verification.	projects/knowledge/interview/git/069-commit-hash.txt
git/4f1cee046a6e	git	medium	git, stash	True or False? To remove a file from git but not from the filesystem, one should use git rm	The question is misleading. `git rm` removes from both git and filesystem. To remove from git tracking but keep the file locally, use `git rm --cached <file_name>`	projects/knowledge/interview/git/031-true-or-false-to-remove-a-file-from-git-but-not-fr.txt
git/50d4332e8620	git	medium	git, bisect	What is the purpose of git bisect?	`git bisect` uses binary search to efficiently find which commit introduced a bug. Start with `git bisect start`, then `git bisect bad` (current) and `git bisect good <commit>`. Git checks out the midpoint; you test and mark good/bad until the culprit is found. Automate with `git bisect run <test-script>`.	projects/knowledge/interview/git/091-git-bisect.txt
git/50fc8e850227	git	medium	git, rebase	How does git revert differ from git reset?	`git revert <commit>` creates a new commit that undoes the specified commit's changes — safe for shared branches. `git reset <commit>` moves HEAD backward, potentially discarding commits. \nKey difference: revert preserves history (safe to push); reset rewrites history (dangerous on shared branches, requires force push).	projects/knowledge/interview/git/085-revert-vs-reset.txt
git/5510c542857a	git	medium	git, rebase	You would like to move forth commit to the top. How would you achieve that?	Use `git rebase -onto` or interactive rebase to reorder commits. \nExample: `git rebase -i HEAD~4` opens an editor where you can reorder lines to change commit order. \nGotcha: reordering rewrites commit hashes, so only do this on unpushed commits. On shared branches, prefer cherry-pick instead.	projects/knowledge/interview/git/022-you-would-like-to-move-forth-commit-to-the-top-how.txt
git/556b931be145	git	easy	git, branching	True or False? A branch is basically a simple pointer to a commit.	TRUE.\n\nGit branches are:\n- Just a pointer (40-byte SHA reference)\n- Stored in .git/refs/heads/\n- Very lightweight to create\n- No copying of files\n\nWhen you create branch:\n- Git creates a file with commit SHA\n- That's it - no data copied\n- Example: .git/refs/heads/feature → abc123...\n\nWhen you commit on branch:\n- Branch pointer moves to new commit\n- Previous commits stay linked\n\nHEAD:\n- Points to current branch\n- Or directly to commit (detached HEAD)\n\nWhy this matters:\n- Branching is cheap\n- Create many branches freely\n- Merging is about commit history, not files	projects/knowledge/interview/git/038-true-or-false-a-branch-is-basically-a-simple-point.txt
git/570a39b7956b	git	medium	git, rebase	What does git revert <commit> do?	It creates a new commit that undoes the changes introduced by the specified commit, without rewriting history (useful for "undoing" a commit in a safe way).	projects/knowledge/interview/git/076-what-does-git-revert-do.txt
git/583ecd61a121	git	easy	git, stash	What is the "staging area" or "index"?	The staging area (also called the index) is a temporary holding zone where changes are assembled before committing. `git add` moves changes into the staging area; `git commit` records the staged snapshot. This two-step process lets you craft precise commits by staging only related changes, even from the same file using `git add -p`.	projects/knowledge/interview/git/067-staging-area.txt
git/60116ea06ae8	git	easy	git, hooks	What is the purpose of a .gitignore file?	It specifies intentionally untracked files that Git should ignore (not show as untracked or stage/commit), such as build artifacts or secrets.	projects/knowledge/interview/git/078-purpose-of-gitignore.txt
git/606d1ff295ae	git	easy	git, log	How do you check the status of your current repository?	`git status` — shows the current state of the working tree and staging area: which files are modified, staged for commit, untracked, or ignored. It also indicates the current branch and its relationship to the upstream remote.	projects/knowledge/interview/git/074-git-status.txt
git/61642cb2dc31	git	medium	git, stash	Explain the following: git directory, working directory and staging area	This answer taken from [git-scm.com](https://git-scm.com/book/en/v1/Getting-Started-Git-Basics#_the_three_states)\n\n"The Git directory is where Git stores the meta-data and object database for your project. This is the most important\npart of Git, and it is what is copied when you clone a repository from another computer.\n\nThe working directory is a single checkout of one version of the project. These files are pulled out of the compressed\ndatabase in the Git directory and placed on disk for you to use or modify.\n\nThe staging area is a simple file, generally contained in your Git directory, that stores information about what will go\ninto your next commit. It's sometimes referred to as the index, but it's becoming standard to refer to it as the staging\narea."	projects/knowledge/interview/git/003-explain-the-following-git-directory-working-direct.txt
git/61ed37114298	git	medium	git, remote	How do you remove a remote branch?	Delete a remote branch with `git push origin --delete <branch_name>` or the older syntax `git push origin :<branch_name>`. This removes the branch on the remote but not locally — run `git branch -d <branch_name>` to clean up the local copy. Use `git fetch --prune` to remove stale remote-tracking references.	projects/knowledge/interview/git/027-how-do-you-remove-a-remote-branch.txt
git/64abbb50cf6a	git	medium	git, rebase	How do you undo the last Git commit?	To undo the last commit, you can use the command git reset HEAD~1. This moves the branch pointer back to the previous commit, effectively removing the last commit. Be cautious when doing this because it discards changes.	projects/knowledge/interview/git/050-how-do-you-undo-the-last-git-commit.txt
git/6550f2549e94	git	medium	git, log	How to list the current git references in a given repository?	`git show-ref` or `find .git/refs/` lists all references (branches, tags, remotes) in the repository. `git show-ref` is the preferred porcelain command as it works on all platforms. References are just files containing SHA-1 hashes — branches under `refs/heads/`, tags under `refs/tags/`, remotes under `refs/remotes/`.	projects/knowledge/interview/git/032-how-to-list-the-current-git-references-in-a-given-.txt
git/65868cd255be	git	medium	git, stash	What is a Git stash, and why would you use it?	A Git stash is like a temporary storage for changes you're not ready to commit. You can "stash" your work, switch to another branch, and later "pop" the stash to continue where you left off.	projects/knowledge/interview/git/049-what-is-a-git-stash-and-why-would-you-use-it-expla.txt
git/668741693e27	git	medium	git, branching	What is a "detached HEAD"?	A detached HEAD occurs when HEAD points directly to a commit SHA instead of a branch name. This happens after `git checkout <commit-hash>` or checking out a tag. \nGotcha: commits made in detached HEAD state are not on any branch and can be garbage-collected. To keep them, create a branch: `git checkout -b new-branch`.	projects/knowledge/interview/git/081-detached-head.txt
git/67cec427b731	git	medium	git, stash	What is git stash used for?	It temporarily shelves (saves) your uncommitted changes so you can work on something else, and you can later apply them with git stash pop.	projects/knowledge/interview/git/075-what-is-git-stash.txt
git/6987f323ac44	git	easy	git, branching	What is a "repository"?	A repository is a data structure that stores project files along with their complete change history, branches, and tags. Git repositories include a `.git` directory containing the object database (blobs, trees, commits), refs, and config. Repositories can be local (on disk) or remote (hosted on GitHub, GitLab, etc.).	projects/knowledge/interview/git/066-what-is-repository.txt
git/7186fdcf638c	git	medium	git, remote	What is the difference between Git commit and Git push?	When you "commit," you're saving your changes to your local repository. When you "push," you're sending those changes to a remote repository, making them available to others.	projects/knowledge/interview/git/043-what-is-the-difference-between-git-commit-and-git-.txt
git/73c971ab1211	git	medium	git, log	How to check if a file is tracked and if not, then track it?	There are different ways to check whether a file is tracked or not:\n  - `git ls-files <file>` -> exit code of 0 means it's tracked\n  - `git blame <file>`\n  ...	projects/knowledge/interview/git/005-how-to-check-if-a-file-is-tracked-and-if-not-then-.txt
git/753a06407b89	git	easy	git, merging	What is a "conflict"?	A conflict occurs when two branches modify the same line in a file and Git cannot automatically merge them. Git marks conflicts with `<<<<<<<`, `=======`, and `>>>>>>>` markers in the file. Resolve by editing the file, removing markers, then `git add` and `git commit`. Use `git mergetool` for a visual diff tool.	projects/knowledge/interview/git/079-what-is-conflict.txt
git/77063f45e423	git	medium	git, rebase	How can you revert a Git commit after it has been pushed to a remote repository?	To revert a commit that has already been pushed to a remote repository, you can use the git revert command. It creates a new commit that undoes the changes made by the original commit without removing it from the history.	projects/knowledge/interview/git/062-how-can-you-revert-a-git-commit-after-it-has-been-.txt
git/7a09bfd292e0	git	easy	git, log	How do you edit the last commit message?	`git commit --amend` replaces the last commit with a new one, letting you fix the message or add forgotten changes. Stage any additional files first with `git add`, then run `git commit --amend`. \nGotcha: amending rewrites the commit hash — never amend commits already pushed to a shared branch without force-pushing.	projects/knowledge/interview/git/093-amend-commit.txt
git/7a334b8897e1	git	medium	git, rebase	How do you discard local commits?	`git reset HEAD~1` removes the last commit but keeps changes in your working directory (mixed mode). `git reset --hard HEAD~1` discards both the commit and all changes permanently. \nGotcha: `--hard` is destructive and cannot be undone easily. If you already pushed, use `git revert` instead to avoid rewriting shared history.	projects/knowledge/interview/git/030-how-do-you-discard-local-commits.txt
git/7b713600f99e	git	easy	git, branching	How do you create a new branch?	`git branch <name>` creates a new branch pointing to the current commit but does not switch to it. Use `git checkout -b <name>` or `git switch -c <name>` to create and switch in one step. \nGotcha: the new branch shares history with its parent — divergence only happens when you make new commits.	projects/knowledge/interview/git/076-create-branch.txt
git/7d63eed95cfc	git	medium	git, rebase	What are the three modes of git reset?	The three modes of `git reset` are: `--soft` (moves HEAD, keeps changes staged), `--mixed` (moves HEAD, unstages changes but keeps them in working directory — this is the default), and `--hard` (moves HEAD, discards all changes permanently). Mnemonic: Soft=Safe(staged), Mixed=Middle(unstaged), Hard=Hazardous(gone).	projects/knowledge/interview/git/086-reset-modes.txt
git/7ed618c6ddba	git	medium	git, hooks	Explain what the file gitignore is used for	The purpose of `gitignore` files is to ensure that certain files not tracked by Git remain untracked. To stop tracking a file that is currently tracked, use git rm --cached.	projects/knowledge/interview/git/006-explain-what-the-file-gitignore-is-used-for.txt
git/8072dd199215	git	medium	git, rebase, merging	What is the difference between git rebase and git merge?	Both integrate changes from one branch into another, but they create\ndifferent history structures.\n\nMerge:\n- Creates a new "merge commit" with two parents\n- Preserves complete history and branch structure\n- Non-destructive: doesn't change existing commits\n- Shows when branches diverged and converged\n\n```\n      A---B---C feature\n     /         \\nD---E---F---G---M main (M is merge commit)\n```	projects/knowledge/interview/git/001-rebase-vs-merge.txt
git/833f51400bd0	git	medium	git, branching	What is Git branching strategy, and why is it important?	A Git branching strategy is a set of rules for creating, naming, and managing branches. It's essential for organized and collaborative development, making it clear which branches are for new features, bug fixes, or releases.	projects/knowledge/interview/git/051-what-is-git-branching-strategy-and-why-is-it-impor.txt
git/85527953fadf	git	medium	git, log	What does `git diff` show and what are its common options?	`git diff` compares working directory vs staging area by default. Key options: `--staged` compares staging vs last commit, `--stat` shows file-level summary, `git diff branch1..branch2` compares branches, and `git diff HEAD~3..HEAD` shows last 3 commits. Add `--name-only` to list changed files without showing the actual diff content.	projects/knowledge/interview/git/033-what-git-diff-does.txt
git/85b7e4746a5f	git	medium	git, log	What git status does?	`git status` helps you to understand the tracking status of files in your repository. Focusing on working directory and staging area - you can learn which changes were made in the working directory, which changes are in the staging area and in general, whether files are being tracked or not.	projects/knowledge/interview/git/008-what-git-status-does.txt
git/85e16c0bb6dd	git	medium	git, branching, merging	What is Git branching and merging, and how do they work?	Git branching is like creating different paths for your project's development. You can make changes separately in each branch. Merging is combining the changes from one branch back into another, creating a unified project with the new features or fixes.	projects/knowledge/interview/git/055-what-is-git-branching-and-merging-and-how-do-they-.txt
git/8aa92be8e9dd	git	easy	git, remote	What does git clone do?	`git clone <url>` creates a local copy of a remote repository including all commits, branches, and tags. It automatically sets up 'origin' as the remote and checks out the default branch. Use `--depth 1` for shallow clones (faster, less disk) or `--bare` for server-side repositories without a working tree.	projects/knowledge/interview/git/070-git-clone.txt
git/8bbc557ffc1f	git	easy	git, branching	True or False? When you git checkout some_branch, git updates HEAD to point to that branch.	TRUE.\n\nWhat checkout does:\n1. Updates HEAD to point to branch\n2. Updates working directory to match\n3. Updates index (staging area)\n\nHEAD file:\n- .git/HEAD contains: ref: refs/heads/some_branch\n- This is how Git knows current branch\n\nExample:\nBefore: HEAD → main\ngit checkout feature\nAfter: HEAD → feature\n\nDetached HEAD:\n- git checkout <commit-sha>\n- HEAD points directly to commit, not branch\n- .git/HEAD contains SHA, not ref\n\nModern alternative:\n- git switch some_branch (for switching)\n- git restore (for file operations)	projects/knowledge/interview/git/039-true-or-false-when-you-git-checkout-somebranch-git.txt
git/8c3d49f34284	git	medium	git, log	What is Git blame (or annotate), and how can it be helpful?	Git blame is like a detective tool for finding out who made changes to a specific line in a file and when. It's useful for tracking down the origin of changes, understanding the context, and identifying who to ask questions if needed.	projects/knowledge/interview/git/061-what-is-git-blame-or-annotate-and-how-can-it-be-he.txt
git/8cf6387a2bd1	git	easy	git, branching	What does git init do?	`git init` creates a new `.git` directory in the current folder, initializing an empty Git repository. This sets up the object database, refs, HEAD, and config files. Use `git init --bare` for server-side repositories that receive pushes but have no working tree. The repo starts with no commits.	projects/knowledge/interview/git/065-git-init.txt
git/92f19eaf30be	git	medium	git, remote	How do you delete a remote branch?	`git push origin --delete <branch-name>` removes a branch from the remote repository. The local branch still exists — delete it separately with `git branch -d <name>`. \nGotcha: other team members' stale remote-tracking refs remain until they run `git fetch --prune` or `git remote prune origin`.	projects/knowledge/interview/git/096-delete-remote-branch.txt
git/94aea28c3822	git	easy	git, log	What does git blame do?	`git blame <file>` annotates each line with the commit hash, author, and date of its last modification. Useful for tracing who introduced a specific change and why. Use `git blame -L 10,20 <file>` to limit to specific lines. Add `-w` to ignore whitespace changes that obscure the real author.	projects/knowledge/interview/git/092-git-blame.txt
git/95604be63ecc	git	medium	git, worktree	A development team in your organization is using a monorepo and it's became quite big, including hundred thousands of files. They say running many git operations is taking a lot of time to run (like git status for example). Why does that happen and what can you do in order to help them?	Many Git operations relate to filesystem state. `git status` compares HEAD vs staging area vs working directory. Key state-related commands:\n\n- `git status`: Shows modified, staged, and untracked files\n- `git stash`: Temporarily shelves working directory changes\n- `git checkout`: Switches branches or restores files\n- `git reset`: Moves HEAD and optionally updates staging/working directory\n- `git clean`: Removes untracked files\n\nUnderstanding the three trees (HEAD, index, working directory) is essential for mastering these commands.	projects/knowledge/interview/git/011-a-development-team-in-your-organization-is-using-a.txt
git/95b67f53a81c	git	medium	git, remote	What is a Git remote?	A Git remote is a reference to a repository hosted on a server. You use it to interact with a repository on platforms like GitHub or GitLab. It allows you to fetch and push changes to and from the remote repository.	projects/knowledge/interview/git/052-what-is-a-git-remote-explanation-imagine-git-remot.txt
git/96f8c49cdfa6	git	easy	git, branching	How do you delete a local branch?	`git branch -d <name>` deletes a local branch that has been fully merged. Use `-D` (capital D) to force-delete an unmerged branch and discard its unique commits. \nGotcha: `-d` is safe — Git refuses if the branch has unmerged work. `-D` is destructive and skips that check.	projects/knowledge/interview/git/095-delete-local-branch.txt
git/9a7e39599b92	git	medium	git, merging	How to resolve git merge conflicts?	\nFirst, you open the files which are in conflict and identify what are the conflicts.\nNext, based on what is accepted in your company or team, you either discuss with your\ncolleagues on the conflicts or resolve them by yourself\nAfter resolving the conflicts, you add the files with `git add <file_name>`\nFinally, you run `git rebase --continue`\n	projects/knowledge/interview/git/018-how-to-resolve-git-merge-conflicts.txt
git/9f7cc56297db	git	medium	git, branching	Describe shortly what happens behind the scenes when you run git branch	Git runs update-ref to add the SHA-1 of the last commit of the branch you're on into the new branch you would like to create	projects/knowledge/interview/git/014-describe-shortly-what-happens-behind-the-scenes-wh.txt
git/a48f8d5392cd	git	medium	git, submodules	What is a "bare repository"?	A bare repository has no working directory — it contains only the `.git` internals (objects, refs, HEAD). Created with `git init --bare`, it is used as a central hub that developers push to and pull from. You cannot edit files or run `git status` in a bare repo. GitHub/GitLab store all repos as bare repositories.	projects/knowledge/interview/git/083-bare-repository.txt
git/a80cc5d0e374	git	easy	git, merging	What is a merge in version control and how does it work?	A merge combines changes from one branch into another, creating a merge commit with two parent commits. Fast-forward merges happen when the target branch has no new commits — Git simply moves the pointer forward. Use `--no-ff` to always create a merge commit for clearer history. Conflicts require manual resolution before completing.	projects/knowledge/interview/git/078-what-is-merge.txt
git/a98868efe4e2	git	medium	git, hooks	What are some Git anti-patterns? Things that you shouldn't do	Common Git anti-patterns: committing too infrequently (huge diffs that are hard to review), committing secrets or credentials, using `git add .` without reviewing changes, force-pushing to shared branches, and poor commit messages like 'fix' or 'update'. Also avoid storing large binaries — use Git LFS instead.	projects/knowledge/interview/git/026-what-are-some-git-anti-patterns-things-that-you-sh.txt
git/acdc7d3e2b65	git	medium	git, stash	How do you revert a specific file to previous commit?	`git checkout HEAD~1 -- /path/to/file` restores a specific file to its state in the previous commit. Replace `HEAD~1` with any commit hash or ref. The file is placed in both the working directory and staging area. Modern alternative: `git restore --source=HEAD~1 /path/to/file`. \nGotcha: this overwrites your current file without warning.	projects/knowledge/interview/git/024-how-do-you-revert-a-specific-file-to-previous-comm.txt
git/b112a1f438f4	git	medium	git, log	What is a Git tag, and why is it used?	A Git tag is like a label for a specific commit, often used to mark significant milestones or releases. It helps you refer to a particular version of your project without having to remember long commit hashes. is a reference point or marker that is used to label a specific commit in a Git repository. Tags are typically used to mark important or significant points in a project's history, such as releases, milestones, or specific versions of the software. They provide a human-readable and permanent way to reference and identify a particular commit.	projects/knowledge/interview/git/057-what-is-a-git-tag-and-why-is-it-used-explanation-a.txt
git/b1a97ec99a88	git	medium	git, log	Describe how `git status` works	`git status` internally runs `git diff` twice: first comparing HEAD to the staging area (showing staged changes), then comparing the staging area to the working directory (showing unstaged changes). Files not in either diff but present on disk appear as untracked. Use `-s` for short format or `-b` to include branch info.	projects/knowledge/interview/git/036-describe-how-git-status-works.txt
git/b284f8cc2a1e	git	medium	git, merging	How do you resolve a Git merge conflict?	To resolve a merge conflict, you need to review the conflicting changes in the affected files and decide which ones to keep. Once resolved, you save the changes, mark the file as resolved, and complete the merge.	projects/knowledge/interview/git/056-how-do-you-resolve-a-git-merge-conflict-explanatio.txt
git/b4f1006cef29	git	medium	git, stash	How do you discard local file changes? (before commit)	`git checkout -- <file>` discards unstaged changes in the working directory, reverting to the staged version. Modern equivalent: `git restore <file>`. \nGotcha: this is permanent — the discarded changes cannot be recovered since they were never committed. Consider `git stash` if unsure.	projects/knowledge/interview/git/029-how-do-you-discard-local-file-changes-before-commi.txt
git/b53fb61f05c8	git	medium	git, stash	What unstaged means in regards to Git?	A file that is in the working directory but is not in the HEAD nor in the staging area is referred to as "unstaged".	projects/knowledge/interview/git/016-what-unstaged-means-in-regards-to-git.txt
git/b67a1cc2f437	git	easy	git, remote	What is the difference between Git and GitHub?	Git is a distributed version control system (the tool) that runs locally. GitHub is a cloud hosting platform for Git repositories that adds collaboration features: pull requests, issues, CI/CD (Actions), code review, and access control. Alternatives to GitHub include GitLab, Bitbucket, and Gitea.	projects/knowledge/interview/git/064-git-vs-github.txt
git/b9450ac47232	git	medium	git, rebase	How to squash last two commits?	Use interactive rebase to combine commits:\n\nMethod 1 - Interactive rebase:\ngit rebase -i HEAD~2\n\nIn editor, change second commit from 'pick' to 'squash':\npick abc123 First commit\nsquash def456 Second commit\n\nSave and edit combined commit message.\n\nMethod 2 - Soft reset:\ngit reset --soft HEAD~2\ngit commit -m "Combined commit message"\n\nMethod 3 - fixup (auto-discard message):\ngit rebase -i HEAD~2\npick abc123 First commit\nfixup def456 Second commit\n\nNote:\n- Don't squash already-pushed commits (rewrites history)\n- Use --force-with-lease if must push after squash\n- Only squash local/unpushed commits	projects/knowledge/interview/git/040-how-to-squash-last-two-commits.txt
git/ba7d9bdd9099	git	easy	git, stash	How do you temporarily save uncommitted changes?	`git stash`. It pushes uncommitted changes onto a stack. `git stash pop` restores them. `git stash list` shows all stashes. Useful when switching branches mid-work.	projects/knowledge/interview/git/082-git-stash.txt
git/bab3d4a534f4	git	medium	git, rebase	Explain Git cherry-pick and when it's useful.	Git cherry-pick is like picking a specific commit from one branch and applying it to another branch. It's handy when you want to include a particular change from one branch into another without merging the entire branch.	projects/knowledge/interview/git/060-explain-git-cherry-pick-and-when-its-useful-explan.txt
git/babe5a4dbb2e	git	medium	git, merging	You have two branches - main and devel. How do you make sure devel is in sync with main?	To sync devel with main: `git checkout main && git pull && git checkout devel && git merge main`. This brings main's latest changes into devel via a merge commit. Alternative: `git checkout devel && git rebase main` for a linear history, but only if devel is not shared. Always pull main first to get the latest remote changes.	projects/knowledge/interview/git/013-you-have-two-branches-main-and-devel-how-do-you-ma.txt
git/bf48a1738d95	git	medium	git, rebase	What does git rebase do?	`git rebase` reapplies your branch's commits on top of another base commit, creating a clean linear history. \nExample: `git checkout feature && git rebase main` replays feature commits after main's HEAD. \nGotcha: rebase rewrites commit hashes — never rebase commits already pushed to a shared branch unless you coordinate with the team.	projects/knowledge/interview/git/084-git-rebase.txt
git/c0c891816277	git	medium	git, merging	What is "squashing" in a merge?	Squashing combines multiple commits into a single commit during a merge, simplifying history. Use `git merge --squash <branch>` to stage all changes from the branch as one commit. Common in PR workflows: a feature branch with 20 WIP commits becomes one clean commit on main. \nGotcha: the original commits are lost from the main branch history.	projects/knowledge/interview/git/100-squash-merge.txt
git/c63042d47ee1	git	easy	git, branching	How do you create a new Git repository?	`git init` in a project directory creates a new Git repository by setting up the `.git` directory structure. Then add files with `git add .` and create the first commit with `git commit -m 'Initial commit'`. To connect to a remote: `git remote add origin <url>` then `git push -u origin main`.	projects/knowledge/interview/git/064-create-new-git-repository.txt
git/c9d76cecbb0f	git	easy	git, branching	How do you create and switch to a new branch in Git?	`git checkout -b <branch-name>` creates a new branch and switches to it in one command. Modern equivalent: `git switch -c <branch-name>`. The new branch starts from your current HEAD. To branch from a specific commit: `git checkout -b <name> <commit-hash>`. Use descriptive names like `feature/add-login` or `fix/null-pointer`.	projects/knowledge/interview/git/069-create-switch-new-branch.txt
git/cc4eb4a1ceae	git	medium	git, merging	What merge strategies are you familiar with?	Mentioning two or three should be enough and it's probably good to mention that 'recursive' is the default one.\n\nrecursive\nresolve\nours\ntheirs\n\nThis page explains it the best: https://git-scm.com/docs/merge-strategies	projects/knowledge/interview/git/019-what-merge-strategies-are-you-familiar-with.txt
git/d1b4617aa703	git	easy	git, remote	What does git push do?	`git push` uploads your local commits to a remote repository, making them available to others. First push requires `-u` flag: `git push -u origin main` sets the upstream tracking branch. \nGotcha: push is rejected if the remote has commits you don't have — `git pull --rebase` first, then push again.	projects/knowledge/interview/git/074-what-does-git-push-do.txt
git/d1d579198afb	git	medium	git, stash	What command removes untracked files from the working directory?	`git clean`. Use `-n` for dry run, `-f` to force delete, `-fd` to include directories. Add `-x` to also remove gitignored files. Always dry-run first.	projects/knowledge/interview/git/094-git-clean.txt
git/d3d9335de83f	git	medium	git, branching	What is Git, and how does it differ from other version control systems?	Git is a version control system that helps you keep track of changes in your project's files. Unlike other systems, Git stores snapshots of your project instead of just the differences between versions.	projects/knowledge/interview/git/041-what-is-git-and-how-does-it-differ-from-other-vers.txt
git/d977bacf294c	git	easy	git, stash	How do you stage changes for commit in Git?	Using git add <file> (or git add . to add all changes), which moves changes into the staging area (index) to be committed.	projects/knowledge/interview/git/065-stage-changes-for-commit.txt
git/dcfd91667450	git	easy	git, remote	What is a "Pull Request"?	A Pull Request (PR) is a request to merge code from one branch into another, enabling code review before merging. PRs show the diff, allow inline comments, run CI checks, and require approvals. Despite the name, a PR is a 'push' of your changes requesting review — GitHub, GitLab (Merge Request), and Bitbucket all support them.	projects/knowledge/interview/git/097-pull-request.txt
git/e05204e0bc82	git	medium	git, rebase	What is git cherry-pick?	`git cherry-pick <commit-hash>` applies a specific commit's changes to your current branch as a new commit. Useful for applying a hotfix from one branch to another without merging the entire branch. \nGotcha: cherry-pick duplicates the commit (new hash), so the same change exists in two places — use sparingly to avoid confusion.	projects/knowledge/interview/git/087-cherry-pick.txt
git/e2d7815d0281	git	medium	git, merging	Explain Git octopus merge	Probably good to mention that it's:\n\n- It's good for cases of merging more than one branch (and also the default of such use cases)\n- It's primarily meant for bundling topic branches together\n\nThis is a great article about Octopus merge: http://www.freblogg.com/2016/12/git-octopus-merge.html	projects/knowledge/interview/git/020-explain-git-octopus-merge.txt
git/e736927efc2c	git	medium	git, log	By which other Git commands does git diff used?	The diff mechanism used by `git status` to perform a comparison and let the user know which files are being tracked	projects/knowledge/interview/git/035-by-which-other-git-commands-does-git-diff-used.txt
git/e8277f224ad4	git	medium	git, branching	What's is the branch strategy (flow) you know?	Major branching strategies: Git Flow (develop/release/hotfix branches — complex, suited for versioned releases), GitHub Flow (feature branches off main, deploy on merge — simpler), Trunk-Based Development (short-lived branches, continuous integration to main — fastest), and GitLab Flow (environment branches like staging/production). Choose based on release cadence and team size.	projects/knowledge/interview/git/012-whats-is-the-branch-strategy-flow-you-know.txt
git/eadc98733ecd	git	medium	git, merging	How do you merge one branch into another?	Check out the target branch (e.g., main) and run git merge <other-branch> to integrate changes from the other branch into the current one.	projects/knowledge/interview/git/071-merge-branch-into-another.txt
git/efe9da2e1c5f	git	easy	git, log	How do you record changes to the repository?	`git commit -m "message"` records staged changes as a new commit in the repository history. Each commit stores a snapshot, parent reference, author, and timestamp. \nBest practice: stage specific files with `git add <file>` rather than `git add .` to keep commits focused. Write imperative messages: 'Add feature' not 'Added feature'.	projects/knowledge/interview/git/068-git-commit.txt
git/f7a2adebdb42	git	medium	git, branching	When you run git branch  how does Git know the SHA-1 of the last commit?	Git reads the HEAD file at `.git/HEAD`, which typically contains `ref: refs/heads/main`. It then reads the SHA-1 from that branch ref file (e.g., `.git/refs/heads/main`). This indirection is what makes branch switching lightweight — only the HEAD pointer changes, not the commit data.	projects/knowledge/interview/git/015-when-you-run-git-branch-how-does-git-know-the-sha-.txt
git/fa0acabd8625	git	easy	git, rebase	What is the difference between git reset and git revert?	\n\n`git revert` creates a new commit which undoes the changes from last commit.\n\n`git reset` depends on the usage, can modify the index or change the commit which the branch head\nis currently pointing at.\n\n	projects/knowledge/interview/git/021-what-is-the-difference-between-git-reset-and-git-r.txt
git/fb7b21b5bdb3	git	medium	git, hooks	Are you familiar with gitattributes? When would you use it?	gitattributes allow you to define attributes per pathname or path pattern. \n\nYou can use it for example to control endlines in files. In Windows and Unix based systems, you have different characters for new lines (\r\n and \n accordingly). So using gitattributes we can align it for both Windows and Unix with `* text=auto` in .gitattributes for anyone working with git. This is way, if you use the Git project in Windows you'll get \r\n and if you are using Unix or Linux, you'll get \n.	projects/knowledge/interview/git/028-are-you-familiar-with-gitattributes-when-would-you.txt
git/fc05feda915a	git	medium	git, log	What is git reflog and how does it help recover lost commits?	`git reflog` records every change to HEAD in the local repository, including commits, resets, rebases, and checkouts. It is your safety net for recovering lost commits after a bad `git reset --hard` or accidental branch deletion. \nExample: `git reflog` then `git checkout <lost-sha>`. Entries expire after 90 days by default.	projects/knowledge/interview/git/088-git-reflog.txt
git/fecdb8f4e15b	git	easy	git, branching	How do you switch between branches?	`git checkout <branch>` or the modern `git switch <branch>` changes your working directory to the specified branch. Git updates files to match the branch's latest commit. \nGotcha: uncommitted changes may be carried over or may cause a conflict — commit or stash first. Use `git switch -` to toggle back to the previous branch.	projects/knowledge/interview/git/077-switch-branches.txt
git/z1a2b3c4d5e6	git	easy	git, branching	What are the four object types in Git's content-addressed database?	Git's content-addressed database has four object types: blob (stores file contents), tree (directory listing mapping names to blob/tree SHAs), commit (snapshot referencing a tree, parent commits, author, and message), and tag (named pointer to a commit with optional metadata and GPG signature). All are identified by their SHA-1 hash.	zines/how.git.works.wizard.zines.cleaned.notes
git/z2b3c4d5e6f7	git	medium	git, log	Does Git store commits as diffs or snapshots?	Git stores each commit as a snapshot of the full tree of blobs and trees. Diffs are computed on demand for display. Pack files use delta compression for storage efficiency, but the logical model is snapshots.	zines/how.git.works.wizard.zines.cleaned.notes
git/z3c4d5e6f7a8	git	medium	git, log	How do you inspect the raw contents of a Git object?	git cat-file -p <hash> prints the object's contents in a human-readable form. Works for blobs, trees, commits, and tags. This is a plumbing command useful for understanding Git internals.	zines/how.git.works.wizard.zines.cleaned.notes
git/z4d5e6f7a8b9	git	medium	git, remote	Why can "up to date with origin/main" be misleading?	origin/main is a local cached ref updated only on fetch. If you have not fetched recently, your origin/main may be stale. Always git fetch before assuming remote state.	zines/how.git.works.wizard.zines.cleaned.notes
git/z5e6f7a8b9c0	git	medium	git, merging	What is the difference between a fast-forward merge and a true merge?	A fast-forward merge simply moves the branch pointer forward (no divergence existed). A true merge creates a merge commit with two parents, combining divergent histories. Fast-forward leaves a linear history.	zines/how.git.works.wizard.zines.cleaned.notes
git/z6f7a8b9c0d1	git	medium	git, rebase	What moves with each mode of git reset?	--soft: moves branch ref only (index and working tree unchanged).\n--mixed (default): moves branch ref and resets index (working tree unchanged).\n--hard: moves branch ref, resets index, and resets working tree. Data loss risk.	zines/how.git.works.wizard.zines.cleaned.notes
git/z7a8b9c0d1e2	git	medium	git, rebase	How do you move a commit from the wrong branch to the correct one?	1. Note the commit SHA.\n2. Switch to the correct branch.\n3. git cherry-pick <sha>.\n4. Switch back to the wrong branch.\n5. git reset --hard HEAD~1 to remove it.\nOnly safe for unpushed commits.	zines/oh.shit.git.cleaned.notes
git/z8b9c0d1e2f3	git	easy	git, stash	How do you stop tracking a file that was accidentally committed?	git rm --cached <path> removes it from the index (staging area) without deleting the working copy. Then add the path to .gitignore to prevent re-adding.	zines/oh.shit.git.cleaned.notes
git/z9c0d1e2f3a4	git	hard	git, rebase	How do you split one commit into two smaller commits?	git reset HEAD~1 (undoes the commit, keeps changes in working tree).\nThen selectively stage with git add -p and commit the first group.\nThen git add and commit the remainder.	zines/oh.shit.git.cleaned.notes
git/zad1e2f3a4b5	git	medium	git, rebase	What should you do when a rebase goes badly wrong?	Run git rebase --abort to return to the pre-rebase state. If you already completed the rebase, use git reflog to find the pre-rebase commit and git reset --hard to that SHA.	zines/oh.shit.git.cleaned.notes
git/zbe2f3a4b5c6	git	hard	git, log	Why might git diff show nothing even though you just changed a file?	Because the changes were already staged with git add. git diff shows working tree vs index. Use git diff --staged to see index vs HEAD. Understanding the three-state model (working tree, index, HEAD) is essential.	zines/oh.shit.git.cleaned.notes
git/zcf3a4b5c6d7	git	medium	git, bisect	What is the first rule of Git disaster recovery?	Stop typing random commands. Name the current state with a branch if needed, inspect the graph and reflog, and prefer reversible steps. Distinguish local-only from already-pushed history before acting.	zines/oh.shit.git.cleaned.notes
git/zda4b5c6d7e8	git	medium	git, branching	How do you save work done in a detached HEAD state?	Run git switch -c <branch-name> (or git checkout -b <branch-name>) to create a new branch pointing to the current commit. Without naming it, the commits become unreachable when you switch away.	zines/how.git.works.wizard.zines.cleaned.notes
git/zeb5c6d7e8f9	git	hard	git, stash	What does git add -p allow you to do and why is it valuable?	It lets you interactively stage individual hunks within a file rather than the entire file. This enables creating focused, logical commits from mixed working-tree changes.	zines/how.git.works.wizard.zines.cleaned.notes

<!-- wiki:related:start -->
---

## Wiki Navigation

### Related Content

- [Git Advanced](../../../../library/topics/git-advanced/index.md) (Topic Pack, L2) — Git
- [Git Drills](../../../../library/drills/git_drills.md) (Drill, L0) — Git
- [Git for DevOps](../../../../library/topics/git/index.md) (Topic Pack, L0) — Git
- [Interview: Secret Leaked to Git](../../../../library/interview-scenarios/13-secret-leaked-to-git.md) (Scenario, L2) — Git
- [Mental Models (Core Concepts)](../../../../library/topics/mental-models-core/index.md) (Topic Pack, L0) — Git
- [RHCE (EX294) Exam Preparation](../../../../library/topics/rhce/index.md) (Topic Pack, L2) — Git
- Repository Flashcards *(CLI)* (flashcard_deck, L1) — Git
- [Skillcheck: Git](../../../../library/skillchecks/git.skillcheck.md) (Assessment, L0) — Git
- [Track: Foundations](../../../../library/curriculum/tracks/foundations.md) (Reference, L0) — Git

<!-- wiki:related:end -->
