Coding practice
Git Coding Questions
12 hands-on challenges with prompts and solution sketches for Git interview rounds.
Challenge set
12 coding questions
1. Stage and Commit
bashStage all and commit with a message.
git add .
git commit -m "Add interview questions hub" 2. Create Branch
bashCreate and switch to a feature branch.
git switch -c feature/coding-hub 3. Rebase Onto Main
bashRebase current branch onto main.
git fetch origin
git rebase origin/main 4. Interactive Soft Reset
bashUndo last commit keep changes staged.
git reset --soft HEAD~1 5. Stash Work
bashStash including untracked files.
git stash push -u -m "wip coding pages" 6. Cherry Pick
bashCherry-pick a commit onto current branch.
git cherry-pick abcdef1 7. Amend Message
bashAmend the last commit message only.
git commit --amend -m "Fix typo in commit message" 8. Show Diff
bashShow staged and unstaged diffs.
git diff
git diff --staged 9. Recover File
bashRestore a deleted tracked file.
git restore --source=HEAD -- path/to/file 10. Bisect Start
bashStart a bisect session.
git bisect start
git bisect bad
git bisect good v1.0.0 11. Clean Untracked
bashPreview then remove untracked files.
git clean -nd
git clean -fd 12. Log Graph
bashShow a compact branch graph.
git log --oneline --graph --decorate -n 20