Integrate and publish

Lesson 17 of 25 · Git: records, branches, and collaboration

Assume local main and the fetched origin/main both exist. Inspect git status and the comparison from the previous lesson. With a clean working tree, select the receiving branch:

git switch main
git merge --ff-only origin/main

This moves local main forward only if it is an ancestor of the fetched tip. If histories diverged, it stops; inspect both sides and choose an appropriate integration strategy with your team. A regular merge may create a merge commit or pause for conflicts. Fetch again when you need a newer view: merge uses the locally stored reference.

git pull --ff-only origin main combines fetch and fast-forward-only integration into the current branch. Check which branch is selected first. Pull’s integration behavior without an explicit option can depend on configuration and history.

To publish committed work, assuming you have permission and a remote named origin:

git push -u origin main

This requests an update to remote main from local main; -u also configures its upstream if the push succeeds. An upstream is a configured relationship used by commands, not continuous synchronization. Push does not send uncommitted edits. A server can reject a push because its branch advanced, permissions are insufficient, or branch rules prohibit it. Fetch and inspect instead of force-pushing over others’ work. Authentication and repository policy govern real network operations.