85.22 Git Merge Remote into Local

20210525 One use case is a fork of a repository as in Section 85.16 (with upstream added as an alias for the remote). For this case the GitHub interface has a Fetch upstream option to merge any upstream commits into the current branch.

Another use case is that someone has forked your repository (and you’ve added downstream as an alias for that remote).

For eaither use case if teh remote repository has been updated and you want to fetch and then merge those updates into your local repository, we can do so from the command line.

First list the named remotes that you may have previously added using remote:

git remote -v

If the remote repository of interest is called upstream then the next step is to fetch updates from the remote:

git fetch upstream

Finally, merge any changes from the remote repository into your local branch:

git merge upstream/main

You may need to resolve any conflicts or else lodge a pull request to the remote and get them to resolve them, though that would be less polite.

Your donation will support ongoing availability and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2021 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0