Skip to content
Foxipa
Code Completion 4 Challenges

Complete the Git commands: Git Push: Publishing Local Refs to a Remote Repository

Create a disposable bare repository and a working clone. Make a local commit, record the local `HEAD`, the remote `refs/heads/main`, and the local `refs/remotes/origin/main`, then run `git push origin main`. Verify the remote ref and transferred commit object, verify the local HEAD did not move, and observe the local remote-tracking ref after the successful push. Next, create a local `topic` branch and push it with `git push origin topic`; verify that the remote topic ref exists. Finally, create genuine divergence in two clones and verify that an ordinary push is rejected without changing the remote tip. Repeat the publication with `--dry-run` first and confirm that the remote remains unchanged until the real push.

Intermediate ~6 min read

Challenge 1

Complete the Git command to publish a local ref.

bash Your answer
git  origin main

Press Ctrl⌘Enter to check your answer

Challenge 2

Complete the Git command to publish a local ref.

bash Your answer
git  origin topic

Press Ctrl⌘Enter to check your answer

Challenge 3

Complete the Git command to publish a local ref.

bash Your answer
git 

Press Ctrl⌘Enter to check your answer

Challenge 4

Complete the Git command to publish a local ref.

bash Your answer
git  origin main:review

Press Ctrl⌘Enter to check your answer