Julia Evans

Dealing with diverged git branches

Diverged branches occur when a local branch and its remote counterpart have different histories. Recognizing divergence is crucial, and ways to do so include `git status`, `git push`, or `git pull`. Resolving divergence depends on the situation. One approach is to keep both changesets by using `git pull --rebase`. To discard remote changes, use `git push --force`, but use `git push --force-with-lease` for added safety. Alternatively, to overwrite local changes, use `git reset --hard origin/main`. These solutions provide options for resolving divergence based on workflow and situation.
favicon
jvns.ca
jvns.ca
Create attached notes ...