| Command | Purpose |
|---|---|
| git init | Initialize a new repository |
| git clone <url> | Download an existing repo from GitHub |
| git status | Show what's changed, staged, untracked |
| git add <file> | Stage a file for the next commit |
| git add . | Stage all changed files |
| git commit -m "msg" | Save staged changes permanently |
| git log --oneline | Compact commit history |
| git diff | Show unstaged changes |
| git branch | List all branches |
| git checkout -b <name> | Create and switch to a new branch |
| git merge <branch> | Merge a branch into the current branch |
| git push origin <branch> | Upload commits to GitHub |
| git pull origin <branch> | Download and merge from GitHub |
| git stash | Save work-in-progress without committing |
| git stash pop | Restore stashed changes |
| git rebase main | Replay your commits on top of latest main |
| git blame <file> | See who changed each line |
Q: How do you manage test automation code in your team?
A: We use Git for version control and GitHub for hosting. The main branch is always stable — all tests pass there. Each tester creates a feature branch for their work, pushes it to GitHub, and creates a Pull Request. The team reviews the PR, and once approved, it gets merged into main. We have a .gitignore that excludes build output, IDE files, test reports, and secrets. Our CI pipeline (Jenkins/GitHub Actions) pulls the latest code from main and runs the full test suite automatically.
Q: What is git stash and when do you use it?
A: git stash temporarily saves your uncommitted changes and gives you a clean working directory. I use it when I need to switch branches urgently but have work in progress that isn't ready to commit. For example, I'm writing a cart test and my lead asks me to fix a broken locator on main. I stash my changes, switch to main, fix the locator, push it, then switch back and run git stash pop to get my half-written test back.
Q: What is the difference between git merge and git rebase?
A: Both integrate changes from one branch into another. git merge creates a new merge commit that joins both branches — the history shows a fork and rejoin. git rebase replays your commits on top of the target branch — the history looks like a straight line. I use rebase to keep my feature branch updated with main (clean history), and merge when actually combining a PR into main. Golden rule: rebase your own private branches, merge shared branches.
Q: Have you ever caused or resolved a merge conflict? Describe it.
A: Yes. In my project, two testers changed the same locator in the LoginPage page object on different branches. When the second PR tried to merge, Git flagged a conflict. I opened the file in VS Code, saw the conflict markers, compared both locator strategies, decided the CSS selector was more stable than the XPath, removed the conflict markers, ran the tests to verify, then committed the resolution. Now we follow a convention of claiming page objects in standups to reduce conflicts.
Q: What is .gitignore and why is it important?
A: The .gitignore file tells Git which files to ignore. In a Selenium project, we ignore build output (target/), IDE files (.idea/), test reports (allure-results/, screenshots/), compiled classes (*.class), and secrets (.env). Without .gitignore, these generated files get committed, bloat the repo, and cause constant merge conflicts. Every team member generates different report files — committing them is pointless noise.
Key Point: Git is the backbone of team collaboration. Master these commands and you'll work confidently in any professional QA team.
Answer all 5 questions, then submit to see your score.
1. What does git add do?
2. Which command creates a new branch AND switches to it?
3. What should you do FIRST when you start your workday?
4. Which files should NEVER be committed in a Selenium project?
5. What happens when you run git stash?