Merge my finished branch into main and push

careful intermediate #merge#main#release#deploy

When to use this: The work on your branch is done and tested, and you want it live on main (and so on Vercel production).

Be careful with this one. Pushing main deploys to production. Make sure the branch preview looks right first.

Before you start

Steps

  1. Switch to main and update it

    terminal
    git switch main
    git pull

    Merge into a fresh main so you do not create conflicts or a rejected push.

  2. Merge the branch

    terminal
    git merge my-branch

    Combines the branch into main. If main did not move, Git fast-forwards with no extra merge commit.

    Expected output
    Updating 3f2a1b9..8c4d7e0
    Fast-forward
  3. Push

    terminal
    git push

    Publishes main. Vercel starts a production deployment.

  4. Tidy up the branch (optional)

    terminal
    git branch -d my-branch
    git push origin --delete my-branch

    -d refuses to delete unmerged work, which is a good safety check.

How to verify it worked

  • git log --oneline -n 5 on main includes your branch's commits.
  • The Vercel dashboard shows a new Production deployment that succeeded.

How to undo it

Pushed and the site is broken: roll the site back in Vercel first (see the rollback scenario), then undo in Git with a revert commit.

terminal
git revert -m 1 <merge-commit-id>

Common errors and fixes

CONFLICT while merging Resolve it (merge-conflict scenario) and commit. Next time, run 'update branch with main' first so conflicts are fixed on the branch.
push rejected main moved on GitHub. git pull, then push again.

Q&A

What is the difference between a fast-forward and a merge commit?

A fast-forward just moves main to your branch's tip because main has nothing new. A merge commit is created when both sides have new commits.

How do I always get a merge commit, even when fast-forward is possible?

git merge --no-ff my-branch. It keeps the branch visible as a unit in history.

Practice these as flashcards →

Terms in this scenario

Related scenarios

My notes

Saved in this browser only.