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