Web Development Version Control 4 — Questions and Answers
Question 1: What does `git remote -v` display?
- The names and URLs of all configured remote repositories (Correct answer)
- The verbose log of all recent remote operations
- All remote branches and their last commit
- The number of commits ahead/behind each remote
Correct answer: The names and URLs of all configured remote repositories
`git remote -v` lists each configured remote alias alongside its fetch and push URLs.
Question 2: Which branching strategy uses long-lived branches like `main`, `develop`, `release`, and `hotfix`?
- Gitflow (Correct answer)
- Trunk-based development
- GitHub Flow
- Feature flag branching
Correct answer: Gitflow
Gitflow defines a strict branching model with specific branch roles for features, releases, and hotfixes around `main` and `develop`.
Question 3: What is the outcome of running `git pull --rebase`?
- Fetches remote changes and rebases your local commits on top of them instead of creating a merge commit (Correct answer)
- Pulls all branches and rebases each one simultaneously
- Reverts your last pull operation
- Pulls changes and squashes them into your current commit
Correct answer: Fetches remote changes and rebases your local commits on top of them instead of creating a merge commit
`git pull --rebase` fetches remote commits then replays your local commits on top, producing a linear history.
Question 4: What does the `HEAD~3` syntax refer to in Git?
- The commit three steps before the current HEAD (Correct answer)
- The third branch in the repository
- Three commits ahead of the remote HEAD
- The HEAD of the third stash entry
Correct answer: The commit three steps before the current HEAD
`HEAD~3` is a relative reference pointing to the great-grandparent commit of the current HEAD.
Question 5: What is the role of a Git 'hook'?
- Scripts that run automatically at specific points in the Git workflow, like before a commit (Correct answer)
- A reference to a remote repository URL
- A method for linking two repositories together
- A special type of tag used in CI/CD pipelines
Correct answer: Scripts that run automatically at specific points in the Git workflow, like before a commit
Git hooks are scripts in the `.git/hooks/` directory that execute automatically on events like `pre-commit`, `post-merge`, or `pre-push`.
Question 6: In a conflict marker, what does the section between `<<<<<<< HEAD` and `=======` represent?
- The changes from your current branch (Correct answer)
- The changes from the branch being merged in
- A backup of the file before either change
- The resolved version chosen automatically by Git
Correct answer: The changes from your current branch
The section under `<<<<<<< HEAD` and before `=======` shows your local branch's version of the conflicting lines.
Question 7: What does `git submodule` allow you to do?
- Include another Git repository as a subdirectory within your repository (Correct answer)
- Split one large repository into smaller modules
- Create a read-only mirror of a repository
- Compress a repository's history into a smaller footprint
Correct answer: Include another Git repository as a subdirectory within your repository
Git submodules let you embed one repository inside another, tracking a specific commit of the embedded repo.
What does `git remote -v` display?