GitHub Interview Questions for Freshers (2026): 60+ Git and GitHub Questions with Commands

What GitHub and Git questions are asked to freshers? Interviewers usually ask the difference between Git and GitHub, the basic commands (clone, add, commit, push, pull), branching and merging, merge vs rebase, how to resolve a merge conflict, how to undo mistakes, what a pull request is, and about the projects on your GitHub profile. Some roles also ask about .gitignore, GitHub Actions and code review. If you can answer these with a real command or a short example, you’re well prepared.
This guide from VibrantMinds Technologies in Pune covers 60+ Git and GitHub interview questions and answers, with commands, a team workflow, a conflict-resolution walkthrough, a GitHub Actions example, a README template, scenario questions and a 14-day plan. If you’ve been searching for GitHub interview questions for freshers, Git interview questions for freshers, Git commands interview questions, git merge vs git rebase, git pull vs git fetch, how to resolve merge conflicts in Git, GitHub Actions for beginners, GitHub profile for freshers or free IT job WhatsApp groups for freshers in Pune, this is built to be the complete answer.
Git and GitHub change over time, and companies may use other platforms such as GitLab or Bitbucket. The concepts here transfer. This guide avoids salary figures and unverified statistics.
Takeaway | Detail |
|---|---|
Git is the tool, GitHub is the platform | Git tracks changes locally. GitHub hosts repositories and adds collaboration features. |
Know the daily workflow | Clone, branch, change, add, commit, push, open a pull request, review, merge. |
Merge vs rebase is a favourite | Be able to explain both and when to use each. |
Know how to undo things |
|
Your repositories are evidence | Clean READMEs, meaningful commits and working projects speak for you. |
Never commit secrets | Passwords, API keys and |
Be honest | Only list projects you can explain line by line. |
HOW GIT AND GITHUB INTERVIEWS USUALLY FLOW
THE BIG PICTURE: THE GIT WORKFLOW
Team workflow in one line: update main → create a feature branch → make small commits → push the branch → open a pull request → get a review → merge → delete the branch.
MODULE 1: GIT AND GITHUB BASICS (Q1 TO Q10)
Q1. What is Git?
Answer: Git is a free, distributed version control system that tracks changes to files, lets multiple people work on the same project and allows you to go back to earlier versions.
Q2. What is GitHub? Git vs GitHub?
Point | Git | GitHub |
|---|---|---|
What it is | Version control tool | Online platform for hosting Git repositories |
Works | Locally on your computer | In the cloud |
Features | Commits, branches, merges | Pull requests, issues, code review, Actions, Pages, project boards |
Alternatives | None needed to compare | GitLab, Bitbucket |
Q3. What is a repository?
Answer: A project folder tracked by Git, containing your files and their full history.
Q4. What is a commit?
Answer: A snapshot of your staged changes with a message and a unique ID (hash). Commits form the project’s history.
Q5. What is a branch?
Answer: An independent line of development. You can work on a feature in a branch without affecting the main code.
Q6. What is “distributed” version control?
Answer: Every developer has a full copy of the repository and its history locally, so most operations work offline and there’s no single point of failure.
Q7. What are the three areas in Git?
Answer: The working directory (your files), the staging area (changes marked for the next commit) and the repository (committed history).
Q8. What is HEAD?
Answer: A pointer to the current commit (usually the latest commit on the current branch).
Q9. What is a remote and what is origin?
Answer: A remote is a version of your repository hosted elsewhere, such as GitHub. origin is the default name given to the remote you cloned from.
Q10. Why do companies use version control?
Answer: To collaborate safely, track who changed what and why, review code, roll back mistakes, work on features in parallel and support continuous integration.
MODULE 2: EVERYDAY COMMANDS (Q11 TO Q22)
Q11. Core commands every fresher must know
bash
Q12. git init vs git clone?
Answer: git init creates a new repository in the current folder. git clone copies an existing remote repository, with its history, to your computer.
Q13. What does git status show?
Answer: The current branch, which files are modified, which are staged and which are untracked.
Q14. git add vs git commit?
Answer: git add moves changes to the staging area. git commit saves the staged changes into the history.
Q15. How do you write a good commit message?
Answer: A short, clear summary in the imperative mood (for example “Fix null check in login service”), optionally followed by a blank line and a detailed explanation. Make small, focused commits rather than one huge commit.
Q16. git pull vs git fetch?
Command | What it does |
|---|---|
| Downloads new commits from the remote without changing your working files |
|
|
Q17. What does git push do, and what if it’s rejected?
Answer: It uploads your local commits to the remote. A rejection usually means the remote has new commits you don’t have. Pull (or fetch and merge or rebase) first, resolve any conflicts, then push again.
Q18. What is .gitignore?
Answer: A file listing patterns of files and folders Git should not track, such as build output, IDE settings, node_modules and secret files.
Q19. How do you stop tracking a file that was already committed?
bash
If a secret was ever pushed, rotate it (change the password or key). Deleting the file later doesn’t remove it from history.
Q20. How do you see the history of a file or who changed a line?
bash
Q21. How do you view differences?
Answer: git diff shows unstaged changes. git diff --staged shows staged changes. git diff branch1..branch2 compares branches.
Q22. What is a tag?
Answer: A named pointer to a specific commit, usually used to mark releases, such as v1.0.0.
bash
MODULE 3: BRANCHING, MERGING AND REBASING (Q23 TO Q32)
Q23. How do you create and switch branches?
bash
Q24. What is merging?
Answer: Combining the changes from one branch into another.
bash
Q25. Fast-forward merge vs three-way merge?
Answer: A fast-forward merge happens when the target branch has no new commits since the branch was created, so Git simply moves the pointer forward. A three-way merge creates a new merge commit when both branches have diverged.
Q26. What is a merge conflict and why does it happen?
Answer: A conflict occurs when two branches change the same part of a file (or one edits a file the other deleted) and Git can’t decide which change to keep. You must resolve it manually.
Q27. How do you resolve a merge conflict?
Answer: Run git status to see conflicted files, open each file, choose the correct code between the conflict markers, remove the markers, git add the file and then complete the merge with git commit (or continue the rebase). The full walkthrough is below.
Q28. What is rebasing?
Answer: Rebasing moves or replays your branch’s commits on top of another branch’s latest commit, producing a linear history.
bash
Q29. Merge vs rebase: the difference
Point | Merge | Rebase |
|---|---|---|
History | Preserves the true history with a merge commit | Rewrites commits to create a linear history |
Safety | Safe for shared branches | Can be risky on shared branches because it rewrites history |
Result | Branch structure is visible | Cleaner, straight-line log |
Typical use | Merging a finished feature into | Updating your own feature branch with the latest |
Golden rule: don’t rebase commits that others have already pulled, because it rewrites shared history.
Q30. What is git cherry-pick?
Answer: It applies a specific commit from one branch onto another.
bash
Q31. What is git stash?
Answer: It temporarily saves your uncommitted changes so you can switch branches and come back later.
bash
Q32. What branching strategies do teams use?
Answer: Commonly: a main branch that stays stable, short-lived feature branches, sometimes a develop branch (Git Flow) and release or hotfix branches. Many teams prefer trunk-based development with small, frequent merges. Follow your team’s convention.
MODULE 4: UNDOING CHANGES SAFELY (Q33 TO Q42)
Q33. How do you undo changes in a file you haven’t staged?
bash
Q34. How do you unstage a file?
bash
Q35. How do you undo the last commit but keep the changes?
bash
Q36. git reset --soft, --mixed and --hard?
Mode | Moves HEAD | Staging area | Working files |
|---|---|---|---|
| Yes | Keeps changes staged | Keeps changes |
| Yes | Unstages changes | Keeps changes |
| Yes | Cleared | Discards changes |
Warning: --hard can permanently discard uncommitted work. Use it carefully.
Q37. git reset vs git revert?
Answer: reset moves the branch pointer and can rewrite history, which is fine for local work. revert creates a new commit that undoes a previous commit, which is the safe way to undo changes that have already been pushed and shared.
bash
Q38. How do you change the last commit message or add a forgotten file?
bash
Don’t amend commits that you’ve already pushed and others may have pulled.
Q39. How do you recover a deleted branch or lost commit?
Answer: Use git reflog, which records where HEAD has pointed recently. Find the commit hash and create a branch from it.
bash
Q40. What is a detached HEAD?
Answer: A state where HEAD points to a specific commit instead of a branch, for example after checking out a commit hash. New commits there aren’t on any branch unless you create one.
Q41. What is git push --force? Is it safe?
Answer: It overwrites the remote branch with your local one and can erase other people’s commits. Avoid it on shared branches. If you must, --force-with-lease is safer because it refuses to overwrite remote changes you haven’t seen.
Q42. You accidentally committed a password. What do you do?
Answer: Rotate the password or key immediately, because it should be considered exposed. Then remove it from the repository history using appropriate tools if needed, add the file to .gitignore and inform your team. Deleting it in a new commit doesn’t remove it from history.
MODULE 5: COLLABORATION ON GITHUB (Q43 TO Q52)
Q43. What is a pull request (PR)?
Answer: A request to merge changes from one branch (or fork) into another on GitHub. It shows the changes, allows discussion and code review, runs checks and ends with a merge.
Q44. What makes a good pull request?
Answer: A clear title and description, small focused changes, linked issue, passing tests and respectful responses to review comments.
Q45. What is code review and why does it matter?
Answer: Teammates review your changes to catch bugs, improve readability, share knowledge and maintain standards. As a fresher, accept feedback positively and ask questions.
Q46. Fork vs clone vs branch?
Term | Meaning |
|---|---|
Fork | Your own copy of someone else’s repository on GitHub, commonly used to contribute to projects you don’t own |
Clone | A copy of a repository on your local machine |
Branch | A line of development inside one repository |
Q47. What are origin and upstream?
Answer: origin is typically your fork or your main remote. upstream is usually the original repository you forked from. Keep your fork updated by fetching from upstream.
bash
Q48. What are GitHub Issues and Projects?
Answer: Issues track bugs, tasks and feature requests. Projects provide boards to organise and plan work. Teams often link pull requests to issues.
Q49. What are the PR merge options on GitHub?
Option | Result |
|---|---|
Create a merge commit | Keeps all commits and adds a merge commit |
Squash and merge | Combines all PR commits into one commit |
Rebase and merge | Replays commits onto the base branch without a merge commit |
Which is used depends on team policy.
Q50. What are branch protection rules?
Answer: Settings that protect important branches (such as main), for example by requiring pull requests, approvals and passing checks before merging.
Q51. SSH vs HTTPS for cloning?
Answer: HTTPS uses a URL with a token or credential manager. SSH uses a key pair you set up once. GitHub no longer accepts account passwords for Git operations over HTTPS, so you use a personal access token or SSH key.
Q52. How do you contribute to an open-source project?
Answer: Find a beginner-friendly issue, fork the repository, create a branch, make your change following the contribution guidelines, push to your fork, open a pull request and respond to review comments.
MODULE 6: GITHUB ACTIONS, SECURITY AND GOOD PRACTICE (Q53 TO Q60)
Q53. What is GitHub Actions?
Answer: GitHub’s automation platform. You define workflows in YAML files that run on events such as a push or pull request, commonly to build, test and deploy code (CI/CD).
Q54. A simple GitHub Actions workflow for a Java Maven project
Create .github/workflows/ci.yml:
yaml
Action versions change, so check the current versions in the official documentation.
Q55. What are GitHub Secrets?
Answer: Encrypted values stored in repository or organisation settings (for example API keys) that workflows can use without exposing them in the code.
Q56. What is CI/CD in simple words?
Answer: Continuous Integration automatically builds and tests code on every change. Continuous Delivery or Deployment automatically prepares or releases the tested code.
Q57. What is GitHub Pages?
Answer: A GitHub feature for hosting static websites (HTML, CSS, JavaScript) directly from a repository, which is useful for portfolios.
Q58. How should a fresher keep a GitHub account professional?
Answer: Use a clear username, a profile photo, a short bio, pinned repositories with good READMEs, meaningful commit messages and no secrets or junk files in your repositories.
Q59. What should never be committed to a repository?
Answer: Passwords, API keys, tokens, private keys, .env files, personal data, large binary files and generated folders like target/ or node_modules/.
Q60. What is a LICENSE file?
Answer: It states how others may use, modify and share your code. For personal portfolio projects it’s optional, but for open-source work choose a licence deliberately. Check licence terms before reusing others’ code.
MERGE CONFLICT WALKTHROUGH (EXPLAIN THIS CLEARLY IN AN INTERVIEW)
The situation: you and a teammate both edited the same line of Greeting.java in different branches.
Step 1: Merge and see the conflict
bash
Step 2: Open the conflicted file
The part between <<<<<<< HEAD and ======= is the current branch’s version. The part between ======= and >>>>>>> is the incoming branch’s version.
Step 3: Choose the correct final code and remove the markers
java
Step 4: Mark it resolved and complete the merge
bash
Tips
Talk to the teammate if the correct choice isn’t obvious
Run the build and tests after resolving
Pull often so conflicts stay small
To cancel a merge in progress:
git merge --abort
YOUR GITHUB PROFILE AND PROJECTS IN INTERVIEWS
Many interviewers open your profile during the interview. Prepare for it.
Profile element | What to do |
|---|---|
Username and photo | Professional and easy to recognise |
Bio | One line: role, key skills, location (for example “Java Developer fresher |
Pinned repositories | Pin your 3 to 6 best projects |
README for each project | Purpose, tech stack, features, setup steps, screenshots |
Commit history | Regular, meaningful commits, not one giant upload |
Clean repositories | No secrets, no |
Branches and pull requests | Use feature branches and PRs even on solo projects to show workflow |
Contribution activity | Consistent real work matters more than green squares |
Questions about your repositories you should be ready for
Question | What a good answer includes |
|---|---|
“Walk me through this repository.” | Purpose, structure, main classes and how to run it |
“Why did you structure it this way?” | Layers, separation of concerns, a genuine reason |
“Show me a commit you’re proud of.” | A meaningful change and what you learned |
“How did you handle a bug?” | The symptom, the debugging steps and the fix |
“What would you improve?” | Tests, validation, security, documentation, performance |
“Did you write all of this yourself?” | Be honest about resources you used, and be able to explain every part |
README TEMPLATE FOR A FRESHER PROJECT (COPY AND ADAPT)
markdown
SCENARIO QUESTIONS
Scenario | A solid approach |
|---|---|
“You committed to the wrong branch.” | Create the correct branch from that commit (or cherry-pick), then reset the wrong branch carefully if the commit isn’t pushed |
“You need to switch tasks but have uncommitted work.” | Use |
“A teammate’s push broke the build.” | Check the failing commit, discuss with the team, and fix forward or use |
“Your push is rejected.” |
|
“You need to undo a pushed commit.” | Use |
“How do you keep your feature branch updated?” | Regularly merge or rebase |
“A secret was pushed.” | Rotate it immediately, remove it from the repository, update |
“How do you review someone’s pull request?” | Read the description, check logic, naming, tests and edge cases, comment politely and suggest improvements |
COMMON MISTAKES FRESHERS MAKE WITH GIT AND GITHUB IN INTERVIEWS
Mistake | Why it hurts | Better approach |
|---|---|---|
Knowing only add, commit, push | Shows limited collaboration experience | Learn branching, PRs and conflict resolution |
Confusing Git and GitHub | Basic concept gap | Git is the tool, GitHub is the platform |
Using | Loses work | Prefer |
Force-pushing to shared branches | Overwrites teammates’ work | Use PRs and |
Committing secrets or build folders | Security risk and unprofessional | Use |
One huge commit with a vague message | Hard to review | Small, clear commits |
Empty or poor READMEs | Recruiters can’t understand the project | Use the README template |
Listing projects you can’t explain | Follow-up questions expose gaps | Pin only projects you understand deeply |
Fake activity to fill the contribution graph | Easy for interviewers to spot | Show real work |
14-DAY GIT AND GITHUB PREPARATION PLAN
Day | Focus | Task |
|---|---|---|
1 | Setup and basics | Install Git, configure your name and email, create a GitHub account and an SSH key or token |
2 | Core commands | Create a repository. Practise |
3 | Remotes | Push to GitHub, clone to another folder, practise |
4 | Branching | Create, switch and merge branches. Try a fast-forward and a three-way merge. |
5 | Merge conflicts | Create a conflict on purpose and resolve it |
6 | Rebase and cherry-pick | Practise on a throwaway repository |
7 | Undoing changes | Practise |
8 |
| Add a proper |
9 | Pull requests | Open and merge a PR on your own repo, then review a friend’s PR |
10 | Fork and contribute | Fork a practice repository and send a small PR |
11 | GitHub Actions | Add a simple CI workflow to a Java or Python project |
12 | README and profile | Write a README for your best project. Update your profile and pinned repositories. |
13 | Revision | Answer Q1 to Q60 aloud and note weak topics |
14 | Mock interview | Explain your best repository for 3 minutes and demonstrate a conflict resolution live |
MYTH VS REALITY
Myth | Reality |
|---|---|
“GitHub is only for senior developers.” | Freshers are expected to know basic Git and to show projects. |
“More commits and green squares mean a better developer.” | Quality and real work matter. Interviewers look at what’s inside. |
“Git is just three commands.” | Real teamwork needs branching, PRs, conflict resolution and undo skills. |
“I should rebase everything.” | Rebase has risks on shared branches. Know when to merge instead. |
“Deleting a committed password fixes the problem.” | It remains in history. Rotate the secret. |
“Private repositories can’t be shown.” | You can discuss them in interviews, but public portfolio projects are easier to share. |
“Copying a tutorial repo is fine.” | Be ready to explain every line and what you changed. |
HOW VIBRANTMINDS HELPS FRESHERS BUILD STRONG GITHUB PROJECTS
VibrantMinds Technologies Pvt. Ltd. is a Pune-based IT training and placement support company. If you searched for VibrantMinds or VibrantMinds Technologies, here is what it offers:
Full Stack Java Development (about 4 to 6 months): Core Java, OOP, JDBC, SQL, Spring Boot, REST APIs, front-end basics, projects, aptitude and interview preparation. Please check the candidate portal for the latest syllabus and tools, including Git and GitHub coverage.
Software Testing (Manual + Automation), Core Java and Python & Data Science for other career paths
Project practice: Build projects you can host on GitHub with clean READMEs and explain confidently
Interview preparation: Technical rounds, project rounds, HR rounds, aptitude, communication and mock interviews
Resume, LinkedIn and GitHub profile guidance: Clear, honest profiles
Placement support: Screening, drive coordination and interview support. Check the campus-drives portal at https://candidates.vibrantminds.in/ for current openings.
Free WhatsApp job alert groups for fresher IT jobs and drives
Honesty first: VibrantMinds offers placement support, not a guaranteed job, and no legitimate recruiter should ask you to pay to be interviewed.
VibrantMinds works as a talent ecosystem connecting candidates, colleges and companies, with 1900+ partner colleges and 600+ hiring companies. Read more fresher job guidance here: https://candidates.vibrantminds.in/blog/fresher-jobs-pune-2026
VIBRANTMINDS COURSES AT A GLANCE
Course | Duration | Key topics |
|---|---|---|
Full Stack Java Development | 4 to 6 months | Core Java, OOP, JDBC, SQL, Spring Boot, REST APIs, front-end basics, projects, aptitude and interview preparation |
Software Testing (Manual + Automation) | 2 to 5 months | Test cases, STLC, bug tracking, SQL, Selenium basics |
Core Java | 1 to 2 months | Syntax, OOP, collections, exceptions, strings |
Python & Data Science | 2 to 4 months | Python basics, data handling, analysis fundamentals |
Fees, syllabus and batch dates are on https://candidates.vibrantminds.in/. Please confirm them directly before enrolling.
THE VIBRANTMINDS PLACEMENT PIPELINE: SIX STEPS
REAL OUTCOMES: WHAT TO EXPECT AND WHAT NOT TO
Past students have shared positive feedback about the training and support, and have gone on to roles at companies such as Aress Software and Education Technologies, Saama Technologies and Three M Software. Results vary by candidate, skill level, effort and market conditions, so please confirm details directly with the VibrantMinds team. No one can honestly promise a guaranteed job.
JOIN FREE VIBRANTMINDS WHATSAPP GROUPS: FRESHER IT JOB UPDATES FOR PUNE AND INDIA
Looking for free WhatsApp groups for IT jobs, a Java WhatsApp group for freshers or a job updates WhatsApp group in India? The VibrantMinds groups share fresher IT openings, campus drives, walk-in interview alerts and interview preparation updates, free of charge. Join whichever group has space. All three carry the same type of updates.
Group | What it offers | Link |
|---|---|---|
VibrantMinds Fresher IT Jobs, Group 1 | Fresher openings, campus drives, walk-in alerts | |
VibrantMinds Fresher IT Jobs, Group 2 | Fresher openings, campus drives, walk-in alerts | |
VibrantMinds Fresher IT Jobs, Group 3 | Fresher openings, campus drives, walk-in alerts |
Never pay to apply. Legitimate recruiters do not charge candidates for tests, interviews or offer letters. Do not share sensitive personal or financial details in any group chat.
FREQUENTLY ASKED QUESTIONS
1. What are the most asked GitHub interview questions for freshers?
Git vs GitHub, repository, commit and branch, the basic commands (clone, add, commit, push, pull), git fetch vs git pull, merge vs rebase, resolving merge conflicts, undoing changes with restore, reset and revert, .gitignore, pull requests and code review, and questions about the projects on your GitHub profile.
2. What is the difference between git merge and git rebase for beginners?
Merge combines branches and keeps the true history, usually with a merge commit. Rebase replays your commits on top of another branch to produce a linear history. Merge is safer for shared branches, while rebase suits updating your own feature branch. Don’t rebase commits others have already pulled.
3. How do I undo the last commit in Git?
If it isn’t pushed, use git reset --soft HEAD~1 to undo the commit but keep your changes staged, or git reset HEAD~1 to keep them unstaged. If it’s already pushed and shared, use git revert <commit> to create a new commit that undoes it safely.
4. How do I explain my GitHub projects in an interview?
Give a short walkthrough: the problem, tech stack, architecture, your role, one challenge you solved and what you’d improve. Keep a clear README, meaningful commits and be ready to open the code and explain any part honestly.
5. Are there free WhatsApp groups for IT fresher jobs in Pune?
Yes. VibrantMinds runs free fresher IT job WhatsApp groups that share openings, campus drives and walk-in alerts. Join through the links above. Always verify any job post and never pay to apply.
CONCLUSION: SHOW YOUR WORK, NOT JUST YOUR COMMANDS
The best preparation for GitHub interview questions for freshers is real use. Practise the daily workflow, create and resolve conflicts on purpose, learn the safe ways to undo changes, open pull requests, add a simple GitHub Actions workflow and keep your repositories clean and well documented. Follow the 14-day plan, practise explaining your projects aloud and stay honest about what you’ve built.
If you’re in Pune and want structured Java, testing or Python training with practice projects, GitHub portfolio guidance, interview preparation and placement support, VibrantMinds Technologies is here to help.
Call to action:
Website: https://vibrantminds.in/
Candidate portal and courses: https://candidates.vibrantminds.in/
Fresher jobs guide: https://candidates.vibrantminds.in/blog/fresher-jobs-pune-2026
Join the free WhatsApp groups: the three links above
VISIT OR CONTACT VIBRANTMINDS IN PUNE
Company: VibrantMinds Technologies Pvt. Ltd.
Address: Viva Academy Building, Warje, Pune, Maharashtra 411052
Phone: +91 95035 79517
Email: support@vibrantmindstech.com
Website: https://vibrantminds.in/
Candidate portal and courses: https://candidates.vibrantminds.in/


