Interview Q&A / Git & GitHub

INTERVIEW Q&A · 97 QUESTIONS

Git & GitHub interview questions

Branching, merge vs rebase, resolving conflicts and pull requests, the way teams actually work.

  1. How do you resolve a merge conflict in Git?

    Run git status to see the conflicted files, open each one and find the markers <<<<<<<, ======= and >>>>>>>. Edit the code to the correct final version, delete the markers, then git add the file and run git commit (or git rebase --continue during a rebase). Test before you push.

    BeginnerIn-depth3 min read
  2. Can you resolve a merge conflict on GitHub without using the command line?

    Yes for simple text conflicts. The pull request page has a Resolve conflicts button that opens an editor with markers; fix them, mark resolved and commit. Complex cases like deleted or binary files need a local merge.

    BeginnerQuick answer1 min read
  3. How can a team reduce merge conflicts?

    Keep branches short-lived, pull or rebase from main often, make small focused pull requests, avoid reformatting whole files, and talk when two people touch the same area.

    BeginnerQuick answer1 min read
  4. How do you cancel a merge that went wrong?

    Run git merge --abort. It restores your branch and working tree to the state before the merge started. It works while the merge is still unresolved and uncommitted.

    BeginnerQuick answer1 min read
  5. What do the <<<<<<<, ======= and >>>>>>> markers in a file mean?

    They are Git's conflict markers. The part between <<<<<<< and ======= is your current branch's version, and the part between ======= and >>>>>>> is the incoming version. You edit the file to the final text and delete all three marker lines.

    BeginnerQuick answer1 min read
  6. How do you cherry-pick a range of commits, and what if there is a conflict?

    Use git cherry-pick A^..B to copy commits from A through B. On conflict, fix the files, git add them and run git cherry-pick --continue, or use --abort to cancel.

    IntermediateQuick answer1 min read
  7. What do --ours and --theirs mean when resolving a conflict?

    In a merge, ours is the branch you are on and theirs is the branch being merged in. git checkout --ours file or --theirs file takes that whole version of the file. In a rebase the meaning is reversed.

    IntermediateQuick answer1 min read
  8. What happens when a conflict occurs during a rebase, and how do you continue?

    Rebase stops at the commit that conflicts. You fix the files, git add them, and run git rebase --continue. You can skip that commit with --skip or give up entirely with --abort.

    IntermediateQuick answer1 min read
  9. What is git rerere?

    rerere means reuse recorded resolution. When enabled, Git remembers how you resolved a conflict and applies the same fix automatically if the same conflict appears again, such as during repeated rebases.

    AdvancedQuick answer1 min read