Rebasing vs. Merging
Which statement best describes the main difference between 'git rebase' and 'git merge' when integrating one branch into another?
- A. Rebase rewrites commit history, while merge adds a new merge commit and preserves history.
- B. Rebase deletes older branches, while merge only copies files over.
- C. Merge creates new branches, whereas rebase removes branches permanently.
- D. Merge deletes the staging area, but rebase resets the repository.
- E. Rebase always overwrites the master branch, but merge cannot be performed on master.
Resolving Conflicts
If you encounter a merge conflict in Git, which of the following is the correct sequence to resolve it?
- A. Edit the conflicted files, use 'git add' to stage changes, then commit.
- B. Run 'git clean', then force push to overwrite conflicts.
- C. Only delete the conflicting branch without making edits.
- D. Use 'git reset βhard' on the repository and re-clone it.
- E. Skip the conflicted file and commit directly.
Reverting Public Commits
Which Git command allows you to undo changes from a commit that has already been pushed to a public repository?
- A. git revert u003Ccommit idu003E
- B. git remove --file
- C. git delete u003Ccommit idu003E
- D. git set-back u003Ccommit idu003E
- E. git reverse u003Ccommit idu003E
Reset vs. Merge Abort
What does the 'git merge --abort' command do during a conflict?
- A. It cancels the merge process and restores the repository to its previous state.
- B. It deletes all files in the repository.
- C. It forcefully commits all changes.
- D. It creates a new branch from the conflicting state.
- E. It stashes the conflicted files automatically.
Listing Changed Files
Which command lists the files that were modified in a specific commit?
- A. git diff-tree -r {commit hash}
- B. git file-change {commit hash}
- C. git list-files {commit hash}
- D. git status -m {commit hash}
- E. git changes --commit {commit hash}
Fixing a Broken Commit
Suppose you want to change the latest commit message or add missed changes. Which command should you use?
- A. git commit --amend
- B. git repair --last
- C. git fixup --amend
- D. git patch --current
- E. git redo --commit
Managing Stashes
If you want to remove the most recent stashed change from the stash list, which Git command would you use?
- A. git stash drop
- B. git stash remove
- C. git stash delete-last
- D. git unstash recent
- E. git pop stash
Cherry-Pick Usage
What is the purpose of the 'git cherry-pick' command?
- A. To apply a specific commit from one branch onto another branch.
- B. To remove unwanted branches from the repository.
- C. To combine all commits into one using rebase.
- D. To compare differences between two branches.
- E. To stash uncommitted changes for later use.
Pull vs. Fetch
Which statement correctly explains the difference between 'git pull' and 'git fetch'?
- A. 'git pull' fetches and merges changes, while 'git fetch' only downloads changes without merging.
- B. 'git fetch' deletes local changes, but 'git pull' only uploads changes.
- C. 'git pull' creates a new repository, but 'git fetch' creates a new branch.
- D. 'git fetch' and 'git pull' are identical and interchangeable.
- E. 'git pull' only works on the master branch, 'git fetch' works on all branches.
Understanding Origin
In Git, what does the term 'origin' usually refer to?
- A. The default name of the remote repository you cloned from.
- B. The time when the project started.
- C. The first file committed in the repository.
- D. The original author of the codebase.
- E. A local directory where branches are created.