I changed things and GitHub changed too: pull, merge, push
When to use this: You worked directly on main locally, GitHub also has new commits (another PC, a merged PR), and you need to combine them and push.
git status is clean. Before you start
Steps
-
Commit what you have
terminalgit add -A git commit -m "Describe my local change"A pull needs a clean working tree, or your edits may be overwritten or block the merge.
-
Preview what is coming
terminalgit fetch git log HEAD..origin/main --onelineSee the remote commits you do not have yet. Optional but it removes surprises.
-
Pull and merge GitHub's changes into your main
terminalgit pull --no-rebaseFetches and merges
origin/maininto yourmain. Git opens an editor for the merge commit message: accept it (save and close). If Git reportsCONFLICT, go to the merge-conflict scenario, then come back.Expected output
Merge made by the 'ort' strategy. src/pages/index.astro | 3 +++
-
Test it
terminalnpm run buildMake sure the combined result still works before you publish it.
-
Push the result back
terminalgit pushUploads your commits and the merge commit. Vercel will deploy
mainto production.
How to verify it worked
git status -sbshows neitheraheadnorbehind.git log --oneline --graph -n 10shows both lines of work joined by a merge commit.
How to undo it
Merged but have NOT pushed, and want to go back to before the pull:
git reset --hard ORIG_HEADAlready pushed a bad merge: do not rewrite history. Revert the merge commit with git revert -m 1 <merge-commit-id> and push.
Common errors and fixes
CONFLICT (content): Merge conflict in <file> Open the file, choose the final text, remove the conflict markers, git add <file>, then git commit. See the merge-conflict scenario. rejected ... fetch first when pushing Someone pushed again while you worked. Repeat the pull, then push. Esc, type :wq, press Enter to save and close. Or :q! to abort the merge commit text. Q&A
Why did Git create a merge commit?
Both histories had new commits, so Git needs a commit that joins them. If you had no local commits it would just fast-forward.
Should I merge or rebase when pulling?
Merge is the safe default: it never rewrites commits. Rebase gives a straighter history but rewrites your local commits, so only use it on commits that are not pushed yet.
Is it safe to work directly on main?
For a solo project, yes, but every push to main deploys to production. A branch plus pull request gives you a preview first.