Git Interview Questions practice questions
10 questions in 1 test. Open one to answer it on its own, or take a whole test.
Test 1
Take Test 1 ›- You add a line X to app.js and run git add app.js. Before committing, you add a second line Y to the same file and save it. You have not staged anything else. An interviewer… · The Three Trees
- On your local feature/search branch you have made three commits named wip, fix typo, and wip 2. None of them has been pushed. Before you open a pull request you want to replace… · Undoing Changes
- Yesterday you pushed a commit to the shared main branch that broke the checkout page. Since then, teammates have pushed four more commits on top of it, and several people have… · Undoing Changes
- On your local branch feature/billing you meant to discard some unstaged edits. Instead you ran git reset --hard HEAD~2. Your last two commits, which were never pushed, no longer… · Recovering Lost Work
- The branch release/2.4 was pushed two weeks ago. Three teammates have since created their own branches from it and pushed commits to it. main now has several security fixes that… · Merge vs Rebase
- A config/local.env file was committed to the repository months ago. You add config/local.env to .gitignore, but every time you edit the file, git status still lists it as… · Tracking & .gitignore
- You and a colleague both push to feature/api. You rebase your local feature/api onto main. While you work, your colleague pushes a new commit X to origin/feature/api. Your IDE… · Remotes & Pushing
- You meant to commit a bug fix to your existing feature/login branch. Instead you committed it to your local main, and you have not pushed. feature/login branched from main a week… · Moving Commits
- A regression appeared somewhere in the last 400 commits. You automate the search with git bisect run ./check.sh. The script builds the project and runs a test. For each commit it… · Debugging with Git
- To reproduce a customer bug, you ran git checkout v2.0, where v2.0 is a release tag. Git warned that you are in "detached HEAD" state. You ignored the warning and made two… · Branches & HEAD