Skip to content
Foxipa
Code Completion 4 Challenges

Complete the Git commands: Git Non-Fast-Forward Rejection: Safe Integration Before Publishing

Create one bare remote and two disposable clones. From clone A, create a local commit without pushing it. From clone B, create and push a different commit. Attempt the stale push from clone A and record the rejection plus the unchanged remote tip. Fetch from A and record the updated `origin/main`. In one disposable copy, merge `origin/main` into A and verify that the resulting merge commit has both histories as ancestors before pushing. In another disposable copy, re-create the divergence, rebase A onto `origin/main`, verify that the local commit identity changed and the remote tip became an ancestor, then push. Finally, create an intentionally rewritten local tip and demonstrate that an explicit `--force-with-lease=<ref>:<expected>` succeeds only when the remote ref still equals the recorded expected object ID.

Intermediate ~6 min read

Challenge 1

Complete the Git command to download remote refs and objects.

bash Your answer
git  origin

Press Ctrl⌘Enter to check your answer

Challenge 2

Complete the Git command to test the relationship between commits.

bash Your answer
git  --is-ancestor refs/remotes/origin/main HEAD

Press Ctrl⌘Enter to check your answer

Challenge 3

Complete the Git command to integrate the selected branch.

bash Your answer
git  --no-edit origin/main

Press Ctrl⌘Enter to check your answer

Challenge 4

Complete the Git command to publish a local ref.

bash Your answer
git  origin main

Press Ctrl⌘Enter to check your answer