Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Merging a git repo from the origin to the upstream repository

Tags:

git

git-merge

Let's say I have an upstream repository, which I have forked to a new origin.

If I want to merge changes from the upstream repo into my forked origin, I would do something like this from within the fork:

$ git merge upstream/master

How would I go the other direction, from origin to upstream? Say I change something in the fork that I want to push to the parent — how would I go about that?

Is it just a matter of setting a new remote/upstream for the parent, using the fork as the parent's upstream?

like image 621
Alex Reynolds Avatar asked Dec 01 '25 14:12

Alex Reynolds


1 Answers

A fork is simply another clone of the original repository.

If you want to share commits/branches between them, add both of them as remotes of your local repository, and then you can decide how to merge and push your commits to which repository.

When you do git merge upstream/master, you join your current one with the master branch of your upstream remote. If you push those changes to upstream (git push upstream master), you'll update your upstream remote. If you push them to your origin remote (git push origin master), you'll be updating your original repository.

like image 112
mgarciaisaia Avatar answered Dec 03 '25 15:12

mgarciaisaia



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!