The Dreaded GitHub Rebase Message
Disclaimer: This is a stupid ass post that basically reflects my inability to remember a simple git command and the fact that I generally work as a solo contributor and don’t hit code merge conflicts often.
If you change your git repo server side and then pull, you may well see this error:
❯ git pull origin main
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 5 (delta 1), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (5/5), 1.42 KiB | 1.42 MiB/s, done.
From github.com:fuzzygroup/imgarr
* branch main -> FETCH_HEAD
d80530e..a954fd6 main -> origin/main
hint: You have divergent branches and need to specify how to reconcile them.
hint: You can do so by running one of the following commands sometime before
hint: your next pull:
hint:
hint: git config pull.rebase false # merge
hint: git config pull.rebase true # rebase
hint: git config pull.ff only # fast-forward only
hint:
hint: You can replace "git config" with "git config --global" to set a default
hint: preference for all repositories. You can also pass --rebase, --no-rebase,
hint: or --ff-only on the command line to override the configured default per
hint: invocation.
fatal: Need to specify how to reconcile divergent branches.
As with many git error messages, this can be disconcerting. Here’s what this means and what to do:
- A change was made to your source code by another committer (either another person or Git itself).
- Your local git installation doesn’t know how to resolve it.
- You have options like rebase or ff (fast forward).
- Git won’t do anything until you tell it what to do.
Here’s the default option I always use which my (very talented) boss, Taylor Williams, at Glass Ivy told me: “Just use rebase; it almost always works perfectly”.
Here’s the git command you need:
git pull origin main --rebase