Master merge conflict resolution, interactive rebasing, selective cherry-picking, history rewriting, git bisect debugging, and branching strategies.
AR
Written by Ashmit N. Rai • Co-Founder & DevOps Platform EngineerDevOps specialist and platform automation architect. Expert in version control workflows.
Interactive Flashcards
# 1
Unreviewed
What is the difference between git merge and git rebase?
Answer Guide
git merge combines branches by creating a new merge commit, preserving the exact historical context and chronology of commits. git rebase rewrites the commit history by applying your branch commits one-by-one on top of the target branch, creating a clean, linear commit history.
Key Concepts Checklist
Evaluate difficulty:
# 2
Unreviewed
What is the difference between git fetch and git pull?
Answer Guide
git fetch downloads commits, files, and refs from the remote repository to your local repository without modifying your working directory. git pull is a combination of git fetch followed immediately by git merge, updating your current local branch with the remote commits.
Key Concepts Checklist
Evaluate difficulty:
# 3
Unreviewed
What is git cherry-pick and when is it useful?
Answer Guide
git cherry-pick <commit-hash> applies the changes introduced by an existing commit from another branch onto your current branch as a new commit. It is useful for pulling a hotfix or specific feature commit from a development branch into production without merging the entire branch.
Key Concepts Checklist
Evaluate difficulty:
# 4
Unreviewed
How do you resolve a Git conflict during a merge?
Answer Guide
1. Git will flag conflicting files. Open the files and locate the conflict markers (<<<<<<<, =======, >>>>>>>). 2. Edit the files to choose which changes to keep, remove the markers. 3. Run "git add <file>" to mark them as resolved. 4. Run "git commit" to complete the merge.
Key Concepts Checklist
Evaluate difficulty:
# 5
Unreviewed
What does git reset --hard do compared to git reset --soft?
Answer Guide
git reset --soft <commit-hash> moves the HEAD pointer to the target commit, but leaves your working directory and staging index unchanged (preserving your changes). git reset --hard <commit-hash> resets the HEAD pointer, index, and working directory, discarding all local modifications.
Key Concepts Checklist
Evaluate difficulty:
# 6
Unreviewed
How do pull requests (PR) and merge requests (MR) work?
Answer Guide
A PR/MR is a proposal to merge changes from one branch (often a feature branch) into another (e.g. main). It provides a interface for team code review, comments, automated CI/CD checks, and discussions before code is merged.
Key Concepts Checklist
Evaluate difficulty:
# 7
Unreviewed
What is a branching strategy? Name a few.
Answer Guide
A branching strategy is a set of rules for how developers write and merge code. Common strategies include GitFlow (main, develop, feature, hotfix branches), GitHub Flow (short-lived feature branches merged directly to main), and Trunk-Based Development (all devs commit directly or via short-lived PRs to a single main branch).
Key Concepts Checklist
Evaluate difficulty:
# 8
Unreviewed
How do you configure git user credentials globally on a new machine?
Answer Guide
Run "git config --global user.name 'Your Name'" and "git config --global user.email 'your.email@example.com'". This writes to the ~/.gitconfig file.
Key Concepts Checklist
Evaluate difficulty:
# 9
Unreviewed
What is a .gitignore file and how does it work?
Answer Guide
A .gitignore file is a text file that lists patterns of files and directories (like node_modules/, .env, build artifacts) that Git should ignore and not track, keeping the repository clean of temporary/local files.
Key Concepts Checklist
Evaluate difficulty:
# 10
Unreviewed
What is git stash and when should you use it?
Answer Guide
git stash temporarily saves (shelves) changes you've made to your working copy so you can work on something else, and then apply them back later. Use it when you need to switch branches quickly but have unfinished work you don't want to commit yet.
Key Concepts Checklist
Evaluate difficulty:
# 11
Unreviewed
What is the difference between git reset and git revert?
Answer Guide
"git reset" moves the current branch HEAD to a previous commit, rewriting history (safe only for local commits). "git revert" creates a new commit that introduces the exact opposite changes of the target commit, preserving project history (safe for public branches).
Key Concepts Checklist
Evaluate difficulty:
# 12
Unreviewed
How do you find which commit introduced a bug in Git?
Answer Guide
Use "git bisect". You start by running "git bisect start", mark the current commit as "bad" ("git bisect bad"), and a past commit as "good" ("git bisect good"). Git will binary search commits, checking out versions for you to test and tag until it isolates the first bad commit.
Key Concepts Checklist
Evaluate difficulty:
Scenario Challenges
Select a scenario below to test your troubleshooting workflow.
Topic: Resolving a Merge Conflict
You pull changes from main and get a conflict in index.html. Resolve the conflict and complete the merge.
Run git status to identify index.html as the conflicting file.Click to select
Open index.html, remove the <<<, ===, >>> markers, and select the correct merged code lines.Click to select
Run git add index.html followed by git commit to finish the merge.Click to select
Selected Sequence
No steps selected yet. Click options above in sequence.
Topic: Cherry-Picking a Hotfix
Apply a critical bugfix commit "b9a1e4" from dev branch onto the production release branch.
Switch to the production branch: git checkout production.Click to select
Apply the bugfix commit: git cherry-pick b9a1e4.Click to select
Resolve any conflicts, verify changes, and push the branch to remote.Click to select
Selected Sequence
No steps selected yet. Click options above in sequence.
Topic: Undoing the Last Commit
You committed files locally but forgot to include config.json. Undo the commit without losing your work.
Run git reset --soft HEAD~1 to undo the commit while leaving your files in the staging area.Click to select
Stage the missing file using git add config.json.Click to select
Execute git commit -m "Your updated commit message" to commit all changes together.Click to select
Selected Sequence
No steps selected yet. Click options above in sequence.
Topic: Cleaning Untracked Files
Remove all untracked test logs and folders from your workspace safely.
Perform a dry run to verify which files will be deleted: git clean -n -d.Click to select
Review the output list to ensure no important untracked files are listed.Click to select
Force remove the untracked files and directories: git clean -f -d.Click to select
Selected Sequence
No steps selected yet. Click options above in sequence.
Topic: Interactive Rebase Squashing
Squash your last 4 commits into a single commit before opening a pull request.
Start interactive rebase: git rebase -i HEAD~4.Click to select
Keep the first commit as "pick" and change "pick" to "squash" (or "s") for the remaining 3 commits.Click to select
Save, combine the commit messages in the editor, and close to finalize the rebase.Click to select
Selected Sequence
No steps selected yet. Click options above in sequence.
We value your privacy
We use cookies to analyze site traffic, personalize content, and support our free educational platforms. By clicking "Accept All", you consent to our use of cookies.