Git pull fails after unrelated histories error

0
2
Asked By MellowBirch42 On

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.

2 Answers

Answered By CopperLynx7 On

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.

MellowBirch42 -

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

CopperLynx7 -

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.

Answered By QuietHarbor18 On

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.

MellowBirch42 -

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

QuietHarbor18 -

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

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.