Question 1
What is the difference between git fetch and git pull?
git fetch downloads remote changes without modifying your current branch, while git pull performs fetch and then merges or rebases those changes into your current branch.
Question 1
git fetch downloads remote changes without modifying your current branch, while git pull performs fetch and then merges or rebases those changes into your current branch.
Question 2
Use rebase to maintain a linear history for feature branches. Use merge when you want to preserve branch context and explicit merge commits.
Question 3
Use git reset --soft HEAD1 to keep changes staged, or git reset --mixed HEAD1 to keep changes unstaged in your working tree.
Question 4
reflog tracks local HEAD movements and helps recover lost commits after operations like reset, rebase, or accidental branch deletion.
Question 5
cherry-pick applies selected commits from one branch to another. It is useful for hotfix backports and selectively moving changes.
Question 6
.gitignore prevents generated artifacts, secrets, and local files from being tracked and accidentally committed.
Question 7
Inspect conflict blocks, keep intended logic, run tests, then mark resolved files with git add and complete merge or rebase.
Question 8
reset moves branch pointers and can rewrite history; revert creates a new commit that undoes earlier changes and is safer on shared branches.
Question 9
Small, focused commits improve code review, make bisect debugging easier, and allow safer rollbacks.
Question 10
git stash temporarily stores uncommitted work so you can switch branches quickly and reapply changes later.
Question 11
Detached HEAD means you are on a commit instead of a branch. New commits are not tied to a branch unless you create one.
Question 12
Branches like origin/main represent remote state locally and are updated by fetch, helping compare local and remote histories.
Question 13
git bisect performs a binary search through commits to identify the exact commit that introduced a bug.
Question 14
Rename locally with git branch -m old new, push the new name, then remove the old remote branch with git push origin --delete old.
Question 15
Fast-forward moves pointers without a merge commit when history is linear; non-fast-forward creates an explicit merge commit.