Courseiva
SDLC Automation →easyMultiple Choice

DOP-C02 SDLC Automation Practice Question

A company uses AWS CodeCommit for source control. Developers report that their local branches are out of sync with the remote repository, and they are unable to push changes because of 'non-fast-forward' errors. What should the developers do to fix this?

⚠ Common exam trap

DOP-C02 often tests the misconception that force-pushing is an acceptable fix for non-fast-forward errors, but the exam expects knowledge of safe collaboration practices like rebasing or merging.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

Pull the latest changes using 'git pull --rebase' and then push.

The 'non-fast-forward' error occurs when the local branch is behind the remote branch, meaning the remote has commits the local doesn't have. Running 'git pull --rebase' fetches the latest remote changes and replays the local commits on top of them, creating a linear history. After this, the local branch is up to date and the push will succeed without needing to force or create a new branch.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    Create a new branch and push that instead.

    Why it's wrong here

    Creating a new branch and pushing that instead does not update the original branch in AWS CodeCommit, so the remote branch remains missing the local commits that caused the rejection. Any developers or pipelines watching the original branch will never see the changes, and the new branch creates a separate line of development that would require a future pull request or merge to integrate. It also fails to address the root cause: the local branch is still behind the remote's new commits.

  • ✗

    Use 'git push --force' to overwrite the remote branch.

    Why it's wrong here

    Using 'git push --force' overwrites the remote branch with your local history, discarding any commits on the remote that are not present locally. This is a non-fast-forward update that can permanently destroy commits created by other team members, break shared feature work, and make the repository's history inconsistent. CodeCommit may also block force pushes through branch policies, but even if allowed, it is dangerous and does not incorporate the remote changes you need.

  • ✓

    Pull the latest changes using 'git pull --rebase' and then push.

    Why this is correct

    Running 'git pull --rebase' fetches the remote branch's new commits and replays your local commits one by one on top of that updated history, producing a linear, fast-forwardable branch. After the rebase, your local branch contains all remote commits, so the subsequent 'git push' is a clean fast-forward rather than a rejected non-fast-forward update. This synchronizes the branch without creating a merge commit or losing any work.

  • ✗

    Delete the remote branch and push again.

    Why it's wrong here

    Deleting the remote branch and pushing again is highly disruptive because it removes a shared reference that other developers, CI/CD pipelines, and CodeCommit pull requests may depend on, making their local clones inconsistent. It also does not solve the rejection: if you have not fetched the remote's latest commits, pushing again from your stale local branch will still be rejected and could orphan existing work when the branch is recreated. The correct fix is to integrate remote changes locally, not destroy the remote ref.

About these practice questions

One of 1,298 original DOP-C02 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Amazon Web Services exam blueprint

This DOP-C02 practice question is part of Courseiva's free Amazon Web Services certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the DOP-C02 exam.