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.β