CPA CPA Version Control & DevOps Practices 1 — Questions and Answers
Question 1: What is the purpose of `git commit` in version control?
- Uploads changes to a remote repository
- Records a snapshot of the staged changes in the local repository history (Correct answer)
- Merges two branches together
- Downloads changes from the remote repository
Correct answer: Records a snapshot of the staged changes in the local repository history
git commit saves a permanent snapshot of all staged changes into the local repository's history with an author, timestamp, and message.
Question 2: In Git, what does the `git pull` command do?
- Pushes local commits to the remote
- Fetches remote changes and merges them into the current local branch (Correct answer)
- Creates a new branch from the remote
- Reverts the last local commit
Correct answer: Fetches remote changes and merges them into the current local branch
git pull is a combination of git fetch (downloading remote changes) and git merge (integrating them into the local branch).
Question 3: What is a Git branch?
- A copy of the entire repository stored on a separate server
- A lightweight movable pointer to a specific commit, enabling parallel lines of development (Correct answer)
- A zipped archive of project source files
- A log file that records all commits
Correct answer: A lightweight movable pointer to a specific commit, enabling parallel lines of development
A Git branch is simply a named reference (pointer) to a commit, allowing developers to diverge from the main codebase and work independently.
Question 4: What is Continuous Integration (CI)?
- Automatically deploying every commit directly to production
- The practice of frequently merging developer code into a shared repository with automated builds and tests (Correct answer)
- A branching strategy that prevents direct commits to main
- A tool for monitoring server uptime
Correct answer: The practice of frequently merging developer code into a shared repository with automated builds and tests
CI is a practice where developers integrate code changes frequently, and each integration triggers automated build and test pipelines to detect errors early.
Question 5: Which Git command creates a new local branch AND switches to it in one step (modern syntax)?
- git branch new-feature && git checkout new-feature
- git switch -c new-feature (Correct answer)
- git init new-feature
- git clone --branch new-feature
Correct answer: git switch -c new-feature
git switch -c <branch> is the modern command that both creates and checks out a new branch in a single step.
Question 6: What does `git rebase` do compared to `git merge`?
- Both commands are identical in effect
- Rebase re-applies commits on top of another base, producing a linear history; merge preserves branch topology (Correct answer)
- Rebase deletes old branches; merge keeps them
- Rebase only works with remote branches
Correct answer: Rebase re-applies commits on top of another base, producing a linear history; merge preserves branch topology
Rebase moves or replays commits onto a new base commit, creating a cleaner linear history, whereas merge creates a merge commit that preserves the original branch structure.
What is the purpose of `git commit` in version control?