DEV Community

Cover image for βœ… *Git & GitHub Interview Questions & Answers(Prt 2)* πŸ§‘β€πŸ’»πŸŒ
ssekabira robert sims
ssekabira robert sims

Posted on

βœ… *Git & GitHub Interview Questions & Answers(Prt 2)* πŸ§‘β€πŸ’»πŸŒ

1️⃣6️⃣ What is a Tag in Git?

A: A tag marks a specific point in history, often used for releases (e.g., v1.0).

1️⃣7️⃣ Difference between Soft, Mixed, and Hard Reset?

  • git reset --soft β†’ Moves HEAD, keeps changes staged
  • git reset --mixed (default) β†’ Moves HEAD, unstages changes
  • git reset --hard β†’ Removes all changes

1️⃣8️⃣ What is Git Revert?

A: Reverts a commit by creating a new one that undoes changes, keeping history intact.

1️⃣9️⃣ What is Cherry Pick?

A: Apply a specific commit from one branch to another without merging the whole branch.

2️⃣0️⃣ What is Git Stash?

A: Temporarily saves uncommitted changes so you can switch branches safely.

2️⃣1️⃣ What is HEAD in Git?

A: A pointer to the current branch reference or latest commit in your working directory.

2️⃣2️⃣ What is the difference between origin and upstream?

  • origin: Default remote repo you cloned from
  • upstream: Original repo you forked from (used in collaboration)

2️⃣3️⃣ What is Fast-forward Merge?

A: When no divergence, Git just moves the branch pointer forward β€” no new commit needed.

2️⃣4️⃣ Git Fetch vs Git Pull

  • Fetch: Downloads changes without merging
  • Pull: Fetch + Merge in one step

2️⃣5️⃣ How to Undo Last Commit?

git reset --soft HEAD~1   # Keeps changes staged
git reset --hard HEAD~1   # Discards changes completely
Enter fullscreen mode Exit fullscreen mode

πŸ’¬ Tap ❀️ for more!

Top comments (0)