Git Basics: Crack Your Next Interview! πŸš€ Quiz

  1. Rebasing vs. Merging

    Which statement best describes the main difference between 'git rebase' and 'git merge' when integrating one branch into another?

    1. A. Rebase rewrites commit history, while merge adds a new merge commit and preserves history.
    2. B. Rebase deletes older branches, while merge only copies files over.
    3. C. Merge creates new branches, whereas rebase removes branches permanently.
    4. D. Merge deletes the staging area, but rebase resets the repository.
    5. E. Rebase always overwrites the master branch, but merge cannot be performed on master.
  2. Resolving Conflicts

    If you encounter a merge conflict in Git, which of the following is the correct sequence to resolve it?

    1. A. Edit the conflicted files, use 'git add' to stage changes, then commit.
    2. B. Run 'git clean', then force push to overwrite conflicts.
    3. C. Only delete the conflicting branch without making edits.
    4. D. Use 'git reset β€”hard' on the repository and re-clone it.
    5. E. Skip the conflicted file and commit directly.
  3. Reverting Public Commits

    Which Git command allows you to undo changes from a commit that has already been pushed to a public repository?

    1. A. git revert u003Ccommit idu003E
    2. B. git remove --file
    3. C. git delete u003Ccommit idu003E
    4. D. git set-back u003Ccommit idu003E
    5. E. git reverse u003Ccommit idu003E
  4. Reset vs. Merge Abort

    What does the 'git merge --abort' command do during a conflict?

    1. A. It cancels the merge process and restores the repository to its previous state.
    2. B. It deletes all files in the repository.
    3. C. It forcefully commits all changes.
    4. D. It creates a new branch from the conflicting state.
    5. E. It stashes the conflicted files automatically.
  5. Listing Changed Files

    Which command lists the files that were modified in a specific commit?

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

    Suppose you want to change the latest commit message or add missed changes. Which command should you use?

    1. A. git commit --amend
    2. B. git repair --last
    3. C. git fixup --amend
    4. D. git patch --current
    5. E. git redo --commit
  7. Managing Stashes

    If you want to remove the most recent stashed change from the stash list, which Git command would you use?

    1. A. git stash drop
    2. B. git stash remove
    3. C. git stash delete-last
    4. D. git unstash recent
    5. E. git pop stash
  8. Cherry-Pick Usage

    What is the purpose of the 'git cherry-pick' command?

    1. A. To apply a specific commit from one branch onto another branch.
    2. B. To remove unwanted branches from the repository.
    3. C. To combine all commits into one using rebase.
    4. D. To compare differences between two branches.
    5. E. To stash uncommitted changes for later use.
  9. Pull vs. Fetch

    Which statement correctly explains the difference between 'git pull' and 'git fetch'?

    1. A. 'git pull' fetches and merges changes, while 'git fetch' only downloads changes without merging.
    2. B. 'git fetch' deletes local changes, but 'git pull' only uploads changes.
    3. C. 'git pull' creates a new repository, but 'git fetch' creates a new branch.
    4. D. 'git fetch' and 'git pull' are identical and interchangeable.
    5. E. 'git pull' only works on the master branch, 'git fetch' works on all branches.
  10. Understanding Origin

    In Git, what does the term 'origin' usually refer to?

    1. A. The default name of the remote repository you cloned from.
    2. B. The time when the project started.
    3. C. The first file committed in the repository.
    4. D. The original author of the codebase.
    5. E. A local directory where branches are created.