Git & GitHub Interview Questions & Answers

Git & GitHub Interview Questions & Answers 🧑💻🌐 1. What is Git? Git is a distributed version control system to track changes in source code during development. 2. What is GitHub? GitHub is a cloud-based platform that hosts Git repositories and supports collaboration, issue tracking, and CI/CD. 3. Git vs GitHub Git: Version control tool (local) GitHub: Hosting service for Git repositories (cloud-based) 4. What is a Repository (Repo)? A storage space where your project’s files and history are saved. 5. Common Git Commands git init → Initialize a repo git clone → Copy a repo git add → Stage changes git commit → Save changes git push → Upload to remote git pull → Fetch and merge from remote git status → Check current state git log → View commit history 6. What is a Commit? A snapshot of your changes. Each commit has a unique ID (hash) and message. 7. What is a Branch? A separate line of development. The default branch is usually main or master. 8. What is Merging? Combining changes from one branch into another. 9. What is a Pull Request (PR)? A GitHub feature to propose changes, request reviews, and merge code into the main branch. 10. What is Forking? A: Creating a personal copy of someone else’s repo to make changes independently. 11. What is .gitignore? A file that tells Git which files/folders to ignore (e.g., logs, temp files, env variables). 12. What is Staging Area? A space where changes are held before committing. 13. Difference between Merge and Rebase Merge: Keeps all history, creates a merge commit Rebase: Rewrites history, makes it linear 14. What is Git Workflow? A set of rules like Git Flow, GitHub Flow, etc., for how teams manage branches and releases. 15. How to Resolve Merge Conflicts? Manually edit the conflicted files, mark resolved, then commit the changes. 16. What is a Tag in Git? A tag marks a specific point in history, often used for releases (e.g., v1.0). 17. 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 18. What is Git Revert? A: Reverts a commit by creating a new one that undoes changes, keeping history intact. 19. What is Cherry Pick? Apply a specific commit from one branch to another without merging the whole branch. 20. What is Git Stash? Temporarily saves uncommitted changes so you can switch branches safely. 21. What is HEAD in Git? A pointer to the current branch reference or latest commit in your working directory. 22. Difference between origin and upstream origin: Default remote repo you cloned from upstream: Original repo you forked from 23. What is Fast-forward Merge? When no divergence, Git just moves the branch pointer forward — no new commit needed. 24. Git Fetch vs Git Pull Fetch: Downloads changes without merging Pull: Fetch + Merge in one step Develop your coding skill JavaScript Mastery #Git #GitHub #InterviewPre #TechSkills

  • No alternative text description for this image

Huge thanks for the mention! We appreciate your support! 🤗

Like
Reply

To view or add a comment, sign in

Explore content categories