Crack the Basics: Easy Git Interview Quiz! Quiz

  1. Branch Integration Methods

    In Git, what is a key difference between using 'rebase' and 'merge' when integrating changes from one branch to another?

    1. A. Rebase moves the feature branch and rewrites history, while merge creates a new commit and preserves all history.
    2. B. Rebase deletes all previous commits, merge does not.
    3. C. Merge can only be used on empty repositories, but rebase cannot.
    4. D. Rebase always results in a conflict, while merge never does.
    5. E. There is no difference between the two.
  2. Resolving Merge Conflicts

    If you encounter a merge conflict while using Git, which step should you perform first?

    1. A. Open the conflicted file and edit it to resolve the issues.
    2. B. Immediately delete the repository.
    3. C. Run the git reset --hard command.
    4. D. Switch to another branch without saving changes.
    5. E. Ignore the conflict and proceed.
  3. Undoing a Public Commit

    If you need to undo a commit that has already been pushed and made public, which Git command is recommended for safely creating a new commit to reverse those changes?

    1. A. git revert u003Ccommit idu003E
    2. B. git delete u003Ccommit idu003E
    3. C. git erase u003Ccommit idu003E
    4. D. git update u003Ccommit idu003E
    5. E. git abort u003Ccommit idu003E
  4. Reset and Abort Commands

    What does the 'git merge --abort' command accomplish?

    1. A. Stops the current merge process and restores the state to before merging began.
    2. B. Deletes the entire repository.
    3. C. Pushes commits to the remote repository.
    4. D. Renames the current branch.
    5. E. Lists all previous commits.
  5. Finding Changed Files

    To list all files changed in a specific Git commit, which command would you use?

    1. A. git diff-tree -r {commit hash}
    2. B. git files-change {commit hash}
    3. C. git list-files {commit hash}
    4. D. git show-diff {commit hash}
    5. E. git commit-log {commit hash}
  6. Fixing a Broken Commit

    Which Git command is commonly used to amend or fix the most recent commit?

    1. A. git commit --amend
    2. B. git fix --latest
    3. C. git repair-commit
    4. D. git correct-last
    5. E. git commit --update
  7. Dropping Stash Items

    If you wish to permanently remove a saved stash entry in Git, which command would you use?

    1. A. git stash drop
    2. B. git stash save
    3. C. git stash pick
    4. D. git stash removeit
    5. E. git stash recall
  8. Using Cherry-Pick

    Suppose you accidentally committed a change to the wrong branch. Which Git command can you use to apply that specific commit to the correct branch?

    1. A. git cherry-pick
    2. B. git apple-pick
    3. C. git pick-branch
    4. D. git branch-pick
    5. E. git change-branch
  9. Pull vs Fetch

    What is the main difference between 'git pull' and 'git fetch'?

    1. A. Git pull fetches and merges commits, while git fetch only downloads commits and leaves merging to the user.
    2. B. Git fetch deletes branches; git pull does not.
    3. C. Git pull works only with tags, git fetch does not.
    4. D. There is no difference; they are identical.
    5. E. Git pull does not create merge commits, git fetch always does.
  10. Understanding Origin

    In Git terminology, what does 'origin' usually refer to?

    1. A. The default name for the remote repository that a project was originally cloned from.
    2. B. The name of your main development branch.
    3. C. A file that stores commit history.
    4. D. The starting point of a Git commit log.
    5. E. Any backup copy of your repository.