Git
Git Command Handbook:
1. Git Configuration & Initial Setup
Configure Git before starting development.
# Check Git version git --version # Configure your identity git config --global user.name "Your Name" git config --global user.email "your.email@example.com" # Configure default branch git config --global init.defaultBranch main # Configure default editor git config --global core.editor "code --wait" # View configuration git config --list git config --global --list git config user.name git config user.email # Initialize a repository git init ### Clone an existing repository git clone <repository_url> git clone <repository_url> <directory_name> git clone --depth 1 <repository_url> # Configure useful aliases git config --global alias.st status git config --global alias.co switch git config --global alias.br branch git config --global alias.lg "log --oneline --graph --decorate --all"
2. Daily Git Workflow – Developer Essentials
Most frequently used commands.
# Check working directory status git status git status -sb # Inspect changes git diff git diff --staged git diff --stat git diff --check # Stage files git add <file> git add <directory> git add . git add -A git add -p - `git add .` – Stage changes in the current directory. - `git add -A` – Stage all changes, including deletions. - `git add -p` – Interactively stage individual changes. # Commit changes git commit -m "feat: add user authentication" git commit -m "fix: resolve login issue" git commit # Commit staged changes and tracked modifications git commit -am "fix: update validation" Note: `-am` does not include new, untracked files. # Amend the latest commit git commit --amend git commit --amend -m "feat: improve authentication" Note: only amend commits that have not already been shared, unless your team explicitly agrees to rewriting history. # Inspect the latest commit git show git show --stat git show --name-only
3. Branch Management & Feature Development
Branches allow developers to work independently without affecting the main development line.
# List branches git branch git branch -a git branch -r # Checkout remote branch git checkout -b branch-name origin/branch-name # Create a branch git branch feature/my-change # Create and switch to a branch git switch -c feature/my-change # Switch branches git switch main git switch develop # Rename a branch git branch -m new-branch-name # Delete a local branch git branch -d feature/my-change git branch -D feature/my-change Note: `-D` force-deletes a branch, even if it has unmerged work. # Delete a remote branch git push origin --delete feature/my-change # Show the current branch git branch --show-current # See which branches contain a commit git branch --contains <commit_sha> # Example: Standard feature development git switch main git pull --ff-only origin main git switch -c feature/user-authentication # Implement changes git status git diff git add -p git commit -m "feat: add user authentication" git push -u origin feature/user-authentication
4. Remote Repository Management
Manage connections to GitHub, GitLab, Bitbucket, and other Git servers.
# Show remote repositories git remote git remote -v # Add a remote git remote add origin <repository_url> # Change remote URL git remote set-url origin <repository_url> # Rename a remote git remote rename origin upstream # Remove a remote git remote remove origin # Download remote updates without merging git fetch git fetch origin git fetch --all git fetch --prune # Download and integrate remote changes git pull git pull origin main git pull --ff-only git pull --rebase # Push changes git push git push origin main git push -u origin feature/my-change git push --force-with-lease Note: prefer `--force-with-lease` over `--force` when rewriting a remote branch. Coordinate with teammates first.
5. Merge, Rebase & Conflict Resolution
Essential for keeping feature branches synchronized with the main development branch.
# Merge another branch into the current branch git merge feature/my-change # Merge without creating a merge commit when possible git merge --ff-only feature/my-change # Create an explicit merge commit git merge --no-ff feature/my-change # Rebase your feature branch onto main git fetch origin git rebase origin/main # Interactive rebase git rebase -i HEAD~5 Useful for: - Squashing commits. - Reordering commits. - Renaming commit messages. - Removing unnecessary commits. # Continue after resolving conflicts git status # Resolve conflicts in files git add <resolved_file> git rebase --continue # Abort a rebase git rebase --abort # Abort a merge git merge --abort # Show conflicting files git diff --name-only --diff-filter=U # Compare branches git diff main..feature/my-change git diff main...feature/my-change git log main..feature/my-change --oneline Important: - `A..B` compares commit ranges. - `A...B` in `git diff` compares B against the merge base of A and B.
6. Git History & Commit Investigation
Important for code reviews, debugging, audits, and understanding how a project evolved.
# Compact commit history git log --oneline git log --oneline -30 git log --oneline --graph --decorate -30 git log --oneline --graph --decorate --all # Full commit details git log -p git log -p -20 # Show one specific commit git show <commit_sha> # Files changed in a commit git show --name-only --oneline <commit_sha> # Added and removed lines git log --stat -20 git log --numstat -20 # Commits for one file git log -- <path/to/file> # Show file history with patches git log -p -- <path/to/file> # Diff of one file in one commit git show <commit_sha> -- <path/to/file> # Search commit messages git log --oneline --grep="fix" git log --oneline --grep="authentication" # Search commits by author git log --author="Your Name" --oneline # Find who changed each line git blame <file> git blame -L 10,50 <file> # Show commits not yet in main git log --oneline main..HEAD # Show only merge commits git log --merges --oneline # Show commits between releases git log --oneline v1.2.0..v1.3.0 # Find which commit introduced or removed a string git log -S "someFunctionName" --oneline -p # Find commits matching a pattern in the diff git log -G 'try[[:space:]]*\{' -p # Custom history format git log --pretty=format:"%h %ad %an %s" --date=short -30 # Show contributors git shortlog -sn git shortlog -sne --all
7. Undo Changes & Recover Work
One of the most important Git topics. Understand these commands before using destructive operations.
# Unstage a file git restore --staged <file> # Discard local changes in a file git restore <file> # Restore a file from another commit git restore --source=<commit_sha> -- <file> # Undo the latest commit but keep changes staged git reset --soft HEAD~1 # Undo the latest commit but keep changes unstaged git reset HEAD~1 # Completely discard the latest commit and its local changes git reset --hard HEAD~1 Warning: `--hard` discards tracked working-tree changes. Make sure you do not need them. # Safely undo a commit that has already been pushed git revert <commit_sha> git push # Revert a merge commit git revert -m 1 <merge_commit_sha> # Recover previous HEAD positions git reflog git reflog --all # Recover a deleted or lost commit git reflog git switch -c recovery-branch <commit_sha> # Remove untracked files (preview first) git clean -n # Remove untracked files git clean -f git clean -fd Warning: `git clean` permanently removes untracked files and directories. Use `-n` first.
8. Stash – Temporarily Save Uncommitted Work
Useful when switching branches or handling urgent production fixes.
# Save current changes git stash git stash push -m "WIP: authentication changes" # Include untracked files git stash -u # List stashes git stash list # Inspect a stash git stash show git stash show -p stash@{0} # Apply latest stash git stash apply # Apply and remove latest stash git stash pop # Apply a specific stash git stash apply stash@{1} # Delete a stash git stash drop stash@{0} # Delete all stashes git stash clear
9. Cherry-Pick – Move Specific Commits Between Branches
Very useful for hotfixes and selectively moving changes between release branches.
# Apply one commit to the current branch git cherry-pick <commit_sha> # Apply multiple commits git cherry-pick <sha1> <sha2> # Apply a range of commits git cherry-pick <old_sha>..<new_sha> Note: This excludes the first commit in the range. # Apply without committing immediately git cherry-pick --no-commit <commit_sha> # Continue after conflict resolution git add <resolved_file> git cherry-pick --continue # Abort cherry-pick git cherry-pick --abort
10. Debugging & Finding Bugs
Powerful commands for developers and technical leads investigating regressions.
# Find the commit that introduced a bug git bisect start git bisect bad git bisect good <known_good_commit> # Git checks out commits between good and bad revisions. Test each one and mark it: git bisect good git bisect bad # When finished: git bisect reset # Automate bisect with a test script git bisect start git bisect bad git bisect good <known_good_commit> git bisect run ./test.sh git bisect reset # Compare two commits git diff <commit1> <commit2> # Find deleted files git log --diff-filter=D --summary # Find commits that changed a specific file git log --follow --oneline -- <file> # Check repository integrity git fsck --full # Check differences in whitespace git diff --check
11. Tags, Releases & Version Management
Especially important for technical leads and DevOps engineers.
# List tags git tag git tag -l # Create a lightweight tag git tag v1.0.0 # Create an annotated release tag git tag -a v1.0.0 -m "Release version 1.0.0" # Tag a specific commit git tag -a v1.0.0 <commit_sha> -m "Release version 1.0.0" # Inspect a tag git show v1.0.0 # Push one tag git push origin v1.0.0 # Push all tags git push origin --tags # Delete a local tag git tag -d v1.0.0 # Delete a remote tag git push origin --delete v1.0.0 # Compare releases git log --oneline v1.0.0..v1.1.0 git diff v1.0.0 v1.1.0
12. Git Worktrees – Work on Multiple Branches Simultaneously
Extremely useful for technical leads, developers, and production hotfixes.
# List existing worktrees git worktree list # Create a new worktree with a new branch git worktree add ../repo-feature -b feature/my-change main ### Create a worktree for an existing branch git worktree add ../repo-hotfix hotfix/urgent-fix # Enter and work normally cd ../repo-feature git status # Remove a worktree git worktree remove ../repo-feature # Prune stale worktree metadata git worktree prune Benefits: - Fix a production issue without interrupting feature development. - Review pull requests in a separate working directory. - Run different branches simultaneously. - Avoid repeatedly switching branches.
13. Advanced Git Operations & Repository Maintenance
# Show all references git show-ref # Show branches and tags containing a commit git branch --contains <sha> git tag --contains <sha> # Show remote tracking information git branch -vv # Set upstream branch git branch --set-upstream-to=origin/main main # Delete stale remote-tracking branches git fetch --prune # Create a patch git format-patch -1 <commit_sha> git format-patch main..HEAD # Apply a patch git apply <patch_file> # Apply a patch as a commit git am <patch_file> # Export a repository snapshot git archive --format=zip --output=release.zip HEAD # Check Git object storage git count-objects -vH # Run repository maintenance git gc git maintenance run # Inspect Git internals git cat-file -p <object_sha> git ls-tree HEAD git rev-parse HEAD
14. Technical Lead – Team Collaboration & Code Review
Commands especially useful when reviewing pull requests, managing team branches, and coordinating development.
# Review all branches git branch -a git branch -vv # Review changes between main and a feature branch git diff main...feature/my-change # Review commits in a feature branch git log --oneline main..feature/my-change # Review files changed by a branch git diff --name-status main...feature/my-change # Review change statistics git diff --stat main...feature/my-change # Find contributors git shortlog -sne --all # Inspect ownership of a file git blame <file> # Find changes from a particular author git log --author="Developer Name" --oneline # Check whether branches have diverged git rev-list --left-right --count main...feature/my-change # Check the merge base git merge-base main feature/my-change # Check commits reachable from one branch but not another git log main..feature/my-change --oneline git log feature/my-change..main --oneline Useful team practices: - Use protected `main` and release branches. - Require pull-request reviews. - Require CI checks before merging. - Use consistent branch naming. - Use conventional commit messages. - Prefer small, focused commits. - Avoid force-pushing shared branches. - Prefer `git revert` for shared history corrections. - Keep feature branches regularly synchronized with main.
15. DevOps – Deployment, Hotfixes & Production Workflows
# Update main before starting work git switch main git fetch origin git pull --ff-only origin main # Create a production hotfix branch git switch main git switch -c hotfix/fix-production-error # Commit and push hotfix git add -p git commit -m "fix: resolve production error" git push -u origin hotfix/fix-production-error # Create a release branch git switch main git switch -c release/1.2.0 # Prepare a release git status git log --oneline main..HEAD git diff main...HEAD # Tag a production release git tag -a v1.2.0 -m "Release version 1.2.0" git push origin v1.2.0 # Synchronize a release branch with main git fetch origin git rebase origin/main # Roll back a production change git revert <commit_sha> git push origin main Follow your organization deployment and approval process before pushing a production rollback. # Inspect exactly what will be deployed git diff <current_release> <target_release> git log --oneline <current_release>..<target_release> # Check the deployed version git describe --tags --always git rev-parse HEAD # Generate release notes git log --pretty=format:"- %h %s" v1.1.0..v1.2.0 Useful CI/CD integration practices: - Build from a known commit SHA. - Tag production releases. - Keep deployment artifacts traceable to Git commits. - Use immutable release identifiers. - Protect deployment branches. - Require automated tests and security checks. - Never commit secrets, tokens, or credentials. - Use rollback commits or known-good release artifacts.
16. Complete Real-World Workflows
## A. Standard Feature Development git switch main git pull --ff-only origin main git switch -c feature/my-change # Develop the feature git status git diff git add -p git commit -m "feat: add my change" git fetch origin git rebase origin/main git push -u origin feature/my-change # Open a pull request and request review ## B. Address Pull Request Feedback git switch feature/my-change # Make requested changes git add -p git commit -m "fix: address PR feedback" git push ## C. Fix a Production Issue While Developing Another Feature # Save unfinished work if necessary git stash -u # Start a separate production fix git switch main git pull --ff-only origin main git switch -c hotfix/fix-prod # Fix the issue git add -p git commit -m "fix: resolve production issue" git push -u origin hotfix/fix-prod # Return to feature development git switch feature/my-change git stash pop ## D. Recover a Mistakenly Deleted Commit git reflog # Find the previous commit SHA git switch -c recovery-branch <commit_sha> ## E. Find Which Commit Introduced a Regression git bisect start git bisect bad git bisect good <known_good_commit> # Test and mark commits git bisect good git bisect bad git bisect reset ## F. Prepare a Release git switch main git pull --ff-only origin main git switch -c release/1.2.0 # Validate release git status git log --oneline -20 git tag -a v1.2.0 -m "Release version 1.2.0" git push origin v1.2.0
Beginner
Q1: What is Git?
Git is a distributed version control system for tracking source code changes.
Q2: Why use Git?
It enables collaboration, history tracking, branching, and safe change integration.
Q3: What is a repository?
A project directory containing files and Git metadata/history.
Q4: What does git init do?
Creates a new local Git repository.
Q5: What does git clone do?
Copies an existing repository (including history) to local machine.
Q6: What is a commit?
Snapshot of staged changes with metadata (author, message, timestamp).
Q7: What is a branch?
Movable pointer to a sequence of commits.
Q8: Why branches are useful?
Isolate work streams (features, fixes, experiments) safely.
Q9: What is HEAD?
Reference to current checked-out commit/branch pointer.
Q10: What is staging area (index)?
Intermediate area where changes are prepared before commit.
Q11: Working tree vs staging area?
Working tree has current file edits; staging contains selected changes for next commit.
Q12: What does git status show?
State of working tree, staged files, and branch info.
Q13: What does git add do?
Stages file changes for commit.
Q14: What does git commit do?
Creates commit from staged changes.
Q15: What does git log do?
Shows commit history.
Q16: What does git diff show?
Line-by-line differences between states (working, staged, commits).
Q17: What does git restore do?
Restores file content from index/commit (modern command family).
Q18: What does git rm do?
Removes file from working tree and stages deletion.
Q19: What does git mv do?
Moves/renames file and stages change.
Q20: What is .gitignore?
File specifying untracked patterns Git should ignore.
Q21: Why use .gitignore?
Avoid committing build artifacts, secrets, temp files.
Q22: What is remote in Git?
Named reference to another repository URL (e.g., origin).
Q23: What does git remote -v show?
Configured remotes and fetch/push URLs.
Q24: What does git fetch do?
Downloads remote updates without merging into current branch.
Q25: What does git pull do?
Fetches and integrates remote changes (merge/rebase depending config).
Q26: What does git push do?
Uploads local commits to remote branch.
Q27: What is merge in Git?
Combining histories from different branches into one.
Q28: What is merge conflict?
Competing changes Git cannot automatically reconcile.
Q29: How resolve merge conflict?
Edit conflicted files, mark resolved (git add), complete merge commit.
Q30: What is fast-forward merge?
Branch pointer moves forward without creating merge commit.
Q31: What is non-fast-forward merge?
Creates explicit merge commit preserving branch topology.
Q32: What is rebase?
Reapplies commits on top of another base commit.
Q33: Rebase vs merge?
Rebase rewrites commit lineage; merge preserves branch history with merge commit.
Q34: Why use rebase?
Cleaner linear history for local feature branches.
Q35: What is cherry-pick?
Apply specific commit(s) onto current branch.
Q36: What is tag?
Named pointer to specific commit, often for releases.
Q37: Lightweight vs annotated tag?
Annotated stores metadata/message/signature; lightweight is simple pointer.
Q38: What is git show?
Displays object details (commit, tag, etc.).
Q39: What is git branch?
Lists/manages branches.
Q40: What is git switch?
Modern command to change/create branches.
Q41: What is detached HEAD?
HEAD points directly to commit, not branch name.
Q42: Is detached HEAD always bad?
No, useful for inspection/testing; commits may be hard to find later unless referenced.
Q43: What is git stash?
Temporarily shelves uncommitted changes.
Q44: When use stash?
Quick context switching without committing partial work.
Q45: What is git stash pop?
Applies latest stash and removes it from stash list.
Q46: What is git stash apply?
Applies stash without removing it.
Q47: What is git reflog?
Local log of where HEAD/refs pointed over time.
Q48: Why reflog is powerful?
Recover “lost” commits after resets/rebases/deletions.
Q49: What is git reset?
Moves branch pointer and optionally index/working tree.
Q50: reset –soft vs –mixed vs –hard?
Soft keeps index/worktree, mixed resets index only, hard resets both index/worktree.
Q51: What is git revert?
Creates new commit undoing effects of an earlier commit.
Q52: Revert vs reset?
Revert preserves public history; reset rewrites local history pointers.
Q53: What is origin?
Default remote name created by clone.
Q54: What is upstream tracking branch?
Default remote branch relationship for pull/push.
Q55: What is git blame?
Shows last modifying commit/author per line.
Q56: What is git grep?
Search text patterns in tracked files quickly.
Q57: Common beginner Git anti-pattern?
Committing generated files and secrets accidentally.
Q58: Another beginner anti-pattern?
Force-pushing shared branches without coordination.
Q59: Beginner commit message baseline?
Short imperative summary + optional body explaining why.
Q60: Beginner branching baseline?
One feature/fix per branch, small focused PRs.
Q61: Beginner safety baseline?
Fetch often, pull before push, resolve conflicts carefully.
Q62: Beginner collaboration baseline?
Use pull requests and code review before merging.
Q63: Beginner recovery baseline?
Use reflog and revert instead of panic.
Q64: Beginner workflow principle?
Commit early, commit logically, keep changes reviewable.
Q65: Beginner best practice?
Treat Git history as communication, not just backup.
Intermediate
Q66: What is three-way merge?
Merge using common ancestor + two branch tips.
Q67: What is octopus merge?
Merge of multiple branches at once (limited conflict handling use cases).
Q68: What is squash merge?
Combines branch commits into one commit at merge time.
Q69: Squash merge tradeoff?
Cleaner main history but loses individual commit granularity on target branch.
Q70: What is rebase –interactive?
Interactive history rewrite (reorder, squash, reword, drop, edit).
Q71: Common interactive rebase use?
Clean up local commits before opening/updating PR.
Q72: What is fixup commit?
Commit marked to auto-squash into target commit later.
Q73: What is autosquash?
Automatically reorder/squash fixup!/squash! commits during rebase.
Q74: What is range-diff?
Compares two commit series (helpful after rebase).
Q75: What is merge-base?
Best common ancestor between branches.
Q76: Why merge-base matters?
Determines diff/merge context and conflict scope.
Q77: What is git bisect?
Binary search through history to find commit introducing bug.
Q78: Why use bisect?
Fast root-cause isolation in large histories.
Q79: What is bisect run?
Automates bisect steps with script/test command.
Q80: What is git clean?
Removes untracked files (optionally directories/ignored files).
Q81: Why git clean dangerous?
Can permanently delete local untracked work.
Q82: What is git restore --staged?
Unstages changes from index without discarding file edits.
Q83: What is git reset HEAD <file> legacy equivalent?
Older way to unstage file.
Q84: What is pathspec in Git?
Pattern syntax selecting specific paths for commands.
Q85: What is partial staging?
Stage selected hunks/lines rather than whole file.
Q86: Why partial staging useful?
Create small logical commits from mixed edits.
Q87: What is git add -p?
Interactive patch staging mode.
Q88: What is signed commit?
Commit cryptographically signed (GPG/SSH/S/MIME).
Q89: Why sign commits/tags?
Authenticity and provenance verification.
Q90: What is protected branch?
Remote branch with policy rules (reviews, checks, no force push).
Q91: Why protect main branch?
Prevents accidental or policy-violating direct changes.
Q92: What is required status check?
CI/test checks that must pass before merge.
Q93: What is linear history enforcement?
Policy requiring no merge commits on protected branch.
Q94: What is merge queue concept?
Serializes validated PR merges to reduce main-branch breakage/races.
Q95: What is CODEOWNERS?
File defining required reviewers for specific paths.
Q96: Why CODEOWNERS helps?
Ensures domain experts review sensitive components.
Q97: What is fork workflow?
Contributors work on personal fork and submit PR to upstream repo.
Q98: Fork vs branch workflow?
Fork isolates permissions; branch workflow uses shared repo branches.
Q99: What is upstream remote in fork model?
Reference to original repository for syncing changes.
Q100: What is git remote prune?
Removes stale remote-tracking references deleted on remote.
Q101: What is git gc?
Garbage collects and optimizes repository storage.
Q102: What is packfile?
Compressed storage format aggregating Git objects efficiently.
Q103: What is shallow clone?
Clone with truncated history depth.
Q104: Shallow clone tradeoff?
Faster clone but limited history operations.
Q105: What is sparse checkout?
Checkout only subset of repository paths.
Q106: Why sparse checkout?
Improve performance in large monorepos when working on subset.
Q107: What is submodule?
Repository embedded at specific commit inside another repository.
Q108: Submodule challenge?
Operational complexity and sync pitfalls.
Q109: What is subtree approach?
Vendor external repo content into subdirectory with merge support.
Q110: Subtree vs submodule?
Subtree simpler consumption; submodule keeps strict repo separation.
Q111: What is LFS (Git Large File Storage)?
Extension storing large binaries outside normal Git object store.
Q112: Why use Git LFS?
Prevent repository bloat and improve clone/fetch performance for binaries.
Q113: What is intermediate anti-pattern?
Rewriting shared history after others based work on it.
Q114: Safe rule for history rewrite?
Only rewrite local/unshared branches unless team explicitly coordinates.
Q115: What is force-with-lease?
Safer force push that checks remote wasn’t unexpectedly updated.
Q116: Why prefer force-with-lease over force?
Prevents overwriting others’ new remote commits accidentally.
Q117: What is release tagging strategy?
Create annotated version tags tied to release commits.
Q118: What is hotfix workflow?
Patch critical issue from release/main branch and merge back appropriately.
Q119: What is backporting?
Applying fix from newer branch to older maintained release branch.
Q120: What is intermediate troubleshooting flow?
status -> log/graph -> reflog -> diff/merge-base -> targeted recovery.
Q121: What is semantic commit convention?
Structured commit messages (feat/fix/chore…) aiding automation.
Q122: Why semantic commits useful?
Changelog generation and release automation.
Q123: What is intermediate security baseline?
Signed commits/tags, protected branches, secret scanning hooks.
Q124: What is intermediate reliability baseline?
Small PRs, required checks, branch protection, rollback-ready tags.
Q125: What is intermediate performance baseline?
Use shallow/sparse clones and LFS where appropriate.
Q126: Intermediate maturity signal?
Team resolves conflicts/rebases confidently without losing history integrity.
Q127: What is intermediate collaboration principle?
Optimize history for both humans (review) and machines (automation).
Q128: What is intermediate governance principle?
Enforce workflow via branch rules and CI, not tribal memory.
Q129: What is intermediate release principle?
Immutable signed tags as deployment source of truth.
Q130: Intermediate best practice?
Prefer transparent, recoverable workflows over clever but fragile Git tricks.
Advanced
Q131: What is Git object model?
Data stored as blobs, trees, commits, and tags addressed by hash IDs.
Q132: What is content-addressable storage in Git?
Object identity derived from content hash for integrity/deduplication.
Q133: Why object model knowledge matters?
Enables advanced recovery, performance tuning, and tooling design.
Q134: What is commit-graph optimization?
Auxiliary structure speeding history walks and queries.
Q135: What are bitmaps in Git packs?
Indexes accelerating clone/fetch object negotiation.
Q136: What is partial clone?
Clone that defers some object downloads until needed.
Q137: Partial clone benefit?
Reduced network/storage for huge repos.
Q138: What is promisor remote concept?
Remote promising missing objects can be fetched on demand.
Q139: What is monorepo Git scaling challenge?
Huge history/tree size impacts clone/status/diff performance.
Q140: Monorepo mitigation techniques?
Sparse checkout, partial clone, repo maintenance, CI optimization.
Q141: What is background maintenance in modern Git?
Automated gc/repack/commit-graph maintenance tasks.
Q142: What is receive-pack/update hook ecosystem?
Server-side hooks enforcing policy on pushes.
Q143: Pre-receive hook use cases?
Block secrets, enforce commit format, deny unsafe refs.
Q144: What is push option mechanism?
Pass custom options to server-side hooks during push.
Q145: What is signed push concept?
Cryptographically signed push certificates (workflow-dependent adoption).
Q146: What is trust-on-first-use risk with Git remotes?
Initial remote authenticity assumptions can be exploited.
Q147: Mitigation for remote trust risk?
Verified URLs, SSH host key validation, signed tags/releases.
Q148: What is dependency confusion relation to Git?
Build pipelines trusting unverified refs/submodules can import malicious code.
Q149: What is branch protection bypass risk?
Admin overrides or misconfigured rules can weaken guarantees.
Q150: Governance mitigation for bypass risk?
Audit logs, limited admin rights, approval workflows.
Q151: What is Gerrit-style workflow concept?
Review-centric model where changes are reviewed before landing, often rebase/cherry-pick based.
Q152: Trunk-based development in Git?
Short-lived branches, frequent integration to main.
Q153: GitFlow model summary?
Structured long-lived branches (develop/release/hotfix) with heavier process.
Q154: Trunk-based vs GitFlow tradeoff?
Speed/simplicity vs explicit release branching control.
Q155: What is rebasing public history incident response?
Coordinate freeze, identify divergence, recover via reflog/cherry-pick/revert plan.
Q156: What is repository corruption recovery concept?
Use fsck, backups, alternate clones, object recovery methods.
Q157: What is git fsck?
Verifies connectivity and validity of Git object database.
Q158: What is secret leak incident in Git history?
Credential committed and propagated through clones/forks.
Q159: Secret leak response steps?
Rotate secret immediately, purge history where required, notify stakeholders, add prevention controls.
Q160: Why rotation before history rewrite?
Assume secret already compromised once exposed.
Q161: What is history rewriting tool for sensitive purge?
Use specialized filtering tools (e.g., git-filter-repo) with coordination.
Q162: What is force-push blast radius at scale?
Breaks clones/branches/PR refs and downstream automation assumptions.
Q163: What is advanced release provenance in Git?
Signed commits/tags + attestations linking source to built artifacts.
Q164: What is reproducible source snapshot concept?
Deterministic archive from exact commit/tag for audits.
Q165: What is code archaeology practice?
Using blame/log/range-diff/bisect to understand why changes happened.
Q166: What is socio-technical value of clean history?
Faster onboarding, debugging, and safer long-term maintenance.
Q167: What is merge strategy option example?
recursive/ort behavior tuning, ours/theirs preferences for conflict cases.
Q168: What is rerere in Git?
Reuse Recorded Resolution; remembers conflict resolutions for reuse.
Q169: Why rerere useful?
Speeds repeated conflict resolution in long-running branches/backports.
Q170: What is advanced anti-pattern in Git?
Treating Git as file sync tool while ignoring review/governance semantics.
Q171: What is platform engineering role for Git workflows?
Define standards, templates, hooks, protections, and training.
Q172: What is policy-as-code for Git operations?
Automated enforcement of branch, commit, and review rules.
Q173: What is auditability requirement in regulated teams?
Traceable authorship, approvals, and release tag integrity.
Q174: What is data retention challenge in Git hosting?
Balancing history permanence with legal/privacy deletion requirements.
Q175: What is disaster recovery for Git platforms?
Repo backups, geo-replication, tested restore procedures.
Q176: What is final reliability principle?
Make integration frequent, reversible, and policy-protected.
Q177: What is final security principle?
Verify identity/integrity of commits, tags, remotes, and CI paths.
Q178: What is final performance principle?
Use advanced clone/index strategies for large repos.
Q179: What is final collaboration principle?
Optimize for small reviews and clear historical intent.
Q180: What is final governance principle?
Automate guardrails; avoid manual enforcement dependency.
Q181: What is final incident-response principle?
Prefer revertable workflows and rehearsed recovery playbooks.
Q182: What is final release principle?
Deploy from signed immutable tags, not moving branch heads.
Q183: What is final scaling principle?
Standardize workflows across repos while allowing bounded team autonomy.
Q184: What is final architecture principle?
Align branching/release model with product delivery cadence.
Q185: Final maturity principle?
Git excellence is trustworthy history, fast collaboration, and resilient recovery.