Git pull fails after unrelated histories error

August 11, 2026 2 answers
Asked by library_volunteer
I'm trying to push changes to a remote repository after running `git status`, `git add .`, and `git commit -m "fifth commit"`. The repositories had different histories, so I tried `git pull origin main --allow-unrelated-histories`. Git then reported that the local and remote branches had diverged and asked me to choose a pull strategy. I ran `git config pull.rebase false`, which selects a merge-based pull, and tried the pull and push commands again. This time I received `fatal: unable to access ... Could not resolve host: github.com`. I'm not sure whether I need to repeat the previous commands once the connection improves or whether something else is wrong.

Answers

!88 transit stops
The final failure is separate from the divergent-branches warning. Your computer couldnโ€™t translate `github.com` into an address, which usually points to a temporary connection issue, DNS trouble, or a slow network. Test the connection first rather than changing more Git settings. After that is fixed, run the pull again and deal with any merge conflicts Git displays.

library_volunteer: The site is already open, but the internet connection is definitely slow.

!88 transit stops: That still fits a temporary network or DNS problem. Wait until the connection is reliable and then retry the command.

Reply to this answer
open mic etiquette
The `pull.rebase false` setting is a valid choice because it tells Git to merge the remote changes into your local branch. The later `Could not resolve host: github.com` error is a network or DNS problem, not a repository-history problem. Check that the site loads in a browser and that your connection or DNS is working. Once the connection is stable, retry the pull command with `--allow-unrelated-histories`; if it succeeds and Git reports merge conflicts, resolve those conflicts, commit the merge, and then push.

library_volunteer: So if the connection comes back, should I just repeat the pull and push steps?

open mic etiquette: Yes, retry the pull after confirming that your computer can resolve and reach the host. You shouldnโ€™t need to keep changing the pull configuration unless Git reports a different error.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions