1. What is GitHub? How is it different from Git?
๐ Answer:
- Git is a distributed version control system used to track code changes.
- GitHub is a cloud-based platform that hosts Git repositories and adds collaboration features.
๐ Use Case:
In a team project, developers use Git locally and push code to GitHub for collaboration, reviews, and CI/CD.
2. What is a Repository?
๐ Answer:
A repository (repo) is a storage space for your project that contains code, files, and version history.
๐ Use Case:
You create a repo for a Playwright automation project where all test scripts, configs, and reports are stored.
3. What is the difference between Fork and Clone?
๐ Answer:
- Fork: Copy of someone elseโs repo into your GitHub account.
- Clone: Copy of a repo to your local machine.
๐ Use Case:
- Fork: Contributing to open-source.
- Clone: Working on your team project locally.
4. What is a Branch?
๐ Answer:
A branch is a separate line of development.
๐ Use Case:
You create:
mainโ production codefeature/login-testโ new feature work
5. What is a Pull Request (PR)?
๐ Answer:
A PR is a request to merge changes from one branch to another.
๐ Use Case:
QA automation engineer raises a PR after adding test cases โ Developer reviews โ merges into main.
6. What is Merge Conflict?
๐ Answer:
Occurs when Git cannot automatically merge changes.
๐ Use Case:
Two developers modify the same file โ conflict โ manually resolved before merge.
7. What is GitHub Actions?
๐ Answer:
A CI/CD tool in GitHub used to automate workflows.
๐ Use Case:
- Run Playwright tests automatically on every PR
- Deploy app after merge
8. What is .gitignore?
๐ Answer:
A file that specifies which files Git should ignore.
๐ Use Case:
Ignore:
node_modules/test-results/.env
9. What is Git Workflow (Branching Strategy)?
๐ Answer:
A process defining how teams use branches.
๐ Common strategies:
- Git Flow
- Feature Branch Workflow
๐ Use Case:
- Create feature branch
- Push code
- Raise PR
- Review โ Merge
10. What is Staging in Git?
๐ Answer:
Intermediate area before committing changes.
๐ Commands:
git add .
git commit -m "message"
๐ Use Case:
You selectively add only required files before committing.
11. Difference between Commit and Push?
๐ Answer:
- Commit: Save changes locally
- Push: Upload changes to GitHub
๐ Use Case:
You commit multiple times locally โ push once after testing.
12. What is Rebase vs Merge?
๐ Answer:
- Merge: Keeps history (creates merge commit)
- Rebase: Rewrites history (linear)
๐ Use Case:
Rebase keeps clean commit history before merging feature branch.
13. What is Tag in Git?
๐ Answer:
A tag marks a specific version of code.
๐ Use Case:
Mark releases like:
v1.0
v2.0
14. What is Git Stash?
๐ Answer:
Temporarily saves uncommitted changes.
๐ Use Case:
You are working on a feature but need to switch branches quickly.
15. What is Code Review in GitHub?
๐ Answer:
Process of reviewing code before merging.
๐ Use Case:
- Developer checks logic
- QA verifies test coverage
- Ensures code quality
๐น Scenario-Based GitHub Interview Questions
16. You pushed wrong code to main branch. What will you do?
๐ Answer:
- Revert commit:
git revert <commit-id>
OR
- Reset (if safe):
git reset --hard HEAD~1
๐ Best Practice:
Avoid direct commits to main โ use PR workflow.
17. Multiple developers working on same feature. How to manage?
๐ Answer:
- Use feature branches
- Regularly pull latest changes
- Resolve conflicts early
๐ Use Case:
Each dev works on sub-features โ merged via PR.
18. How do you handle large files in GitHub?
๐ Answer:
Use Git LFS (Large File Storage).
๐ Use Case:
Store large test data or binaries.
19. How do you secure sensitive data in GitHub?
๐ Answer:
- Never commit secrets
- Use GitHub Secrets
- Use
.gitignore
๐ Use Case:
Store API keys in environment variables.
20. Explain CI/CD pipeline using GitHub Actions
๐ Answer:
- Code pushed to GitHub
- Workflow triggers
- Build runs
- Tests execute
- Deploy
๐ Use Case:
Playwright tests run automatically on every commit.
๐น Advanced Practical Questions
21. How do you revert a specific file to previous version?
git checkout <commit-id> -- file.js
22. How do you squash commits?
git rebase -i HEAD~3
๐ Combine multiple commits into one.
23. What is Detached HEAD?
๐ Answer:
When you’re not on any branch.
๐ Use Case:
Checking old commit without affecting current branch.
24. How do you delete a branch?
git branch -d branch-name
git push origin --delete branch-name
25. What is Upstream in Git?
๐ Answer:
Reference to original repository (especially in forks).
๐ Use Case:
Keep your fork updated with original repo.
Mock Interview: GitHub (Real Company Style)
๐น Round 1: Basics + Practical Understanding
โ Q1: Explain your GitHub workflow in your current project.
๐ Strong Answer:
โWe follow a feature branch workflow. Each task starts with a new branch from
main. After development, we push code and raise a pull request. CI runs automatically using GitHub Actions. After code review and approvals, we merge intomain. Direct commits tomainare restricted.โ
๐ What interviewer checks:
- Real experience
- Collaboration understanding
- CI/CD awareness
โ Q2: What happens when you run git push?
๐ Strong Answer:
โIt uploads local commits from my machine (using Git) to the remote repository on GitHub, making them available to the team.โ
๐ Follow-up trap:
๐ โWhat if push is rejected?โ
โ๏ธ Answer:
โIt usually means my branch is behind. I pull the latest changes, resolve conflicts if any, and push again.โ
๐น Round 2: Scenario-Based Questions
โ Q3: You and another developer changed the same file. Your PR shows conflict. What do you do?
๐ Strong Answer:
โI pull the latest changes from
main, resolve conflicts locally, test the code, commit the fix, and push again to update the PR.โ
๐ Bonus point:
Mention testing after conflict resolution.
โ Q4: You accidentally pushed sensitive data (API key) to GitHub. What will you do?
๐ Strong Answer:
โFirst, I revoke the key immediately. Then I remove it from the repository, rewrite history if needed, and ensure it’s added to
.gitignore. Going forward, I store secrets using GitHub Secrets.โ
๐ What interviewer checks:
- Security awareness
- Real-world handling
โ Q5: Your teammateโs PR broke the build. What should happen?
๐ Strong Answer:
โThe CI pipeline should fail automatically. The PR should not be merged until the issue is fixed. We enforce required checks before merging.โ
๐ Extra credit:
Mention branch protection rules.
๐น Round 3: CI/CD + Automation (Very Important)
โ Q6: How do you integrate automation tests with GitHub?
๐ Strong Answer:
โWe use GitHub Actions to trigger Playwright tests on every PR. The workflow installs dependencies, runs tests, and publishes reports.โ
๐ Example flow:
- PR created
- Tests run automatically
- Pass โ merge allowed
- Fail โ fix required
โ Q7: How do you ensure code quality before merging?
๐ Strong Answer:
โWe use a combination of:
- Pull request reviews
- Automated tests
- Linting checks
- CI validation
Only after all checks pass, the PR is merged.โ
๐น Round 4: Advanced Problem Solving
โ Q8: Your main branch is broken after a merge. What will you do?
๐ Strong Answer:
โI would quickly identify the faulty commit and revert it using
git revert. Then fix the issue in a new branch and raise another PR.โ
๐ Important:
Avoid rewriting history in shared branches.
โ Q9: How do you handle multiple environments (dev, staging, prod)?
๐ Strong Answer:
โWe use different branches or deployment workflows. For example:
developโ dev environmentmainโ production
CI/CD pipelines deploy automatically based on branch.โ
โ Q10: How do you manage large teams working on the same repo?
๐ Strong Answer:
โWe use:
- Feature branches
- Clear naming conventions
- Code owners
- Mandatory PR reviews
- CI/CD checks
This ensures smooth collaboration and avoids conflicts.โ
๐น Round 5: Rapid Fire (Quick Checks)
โ Difference between Fork and Clone?
๐ Fork = copy on GitHub
๐ Clone = copy on local machine
โ What is HEAD in Git?
๐ Pointer to the current commit/branch
โ What is Rebase?
๐ Rewrites commit history to make it linear
โ What is Stash?
๐ Temporarily saves uncommitted changes
โ What is a Tag?
๐ Marks a release/version
๐น Real Interview Challenge (Hands-On Thinking)
โ Q11: Design a GitHub workflow for automation testing.
๐ Strong Answer:
โI would:
- Trigger workflow on PR and push
- Install dependencies
- Run Playwright tests
- Generate reports
- Upload artifacts
- Fail build if tests fail
This ensures only tested code gets merged.โ
๐น Final HR + Practical Question
โ Q12: Tell me a real problem you faced in GitHub and how you solved it.
๐ Sample Answer:
โWe had frequent merge conflicts due to long-running branches. I suggested smaller PRs and frequent rebasing. This reduced conflicts and improved deployment speed.โ