Reputation: 61
I am taking a class which has a classwide github repo to publish labs, docs, etc. I want to fork this, do my own work on the labs, and push to my private git repo. However, I still want to be able to pull changes from the class github. Is there a way to do this?
Thanks
Upvotes: 0
Views: 1343
Reputation: 4088
Yes, for sure, the key is in your repo remotes, so your fork have a remote called "origin" and for the original repo create a remote called upstream.
create the upstream remote with following command
git remote add upstream https://github.com/user/original.git
Then validate your remotes
git remote -v
origin https://github.com/your-user/fork.git (fetch)
origin https://github.com/your-user/fork.git (push)
upstream https://github.com/user/original.git (fetch)
upstream https://github.com/user/original.git (push)
So now you can push and pull from the original repo
git pull upstream branch
git push upstream branch
In the other way you can create a pull request directly in Github
Upvotes: 0
Reputation: 270
set up two remote branches, one for your private and one to the class
git remote add classwide sshblah
git remote add private sshblah
then you can
git fetch classwide
to grab your class stuff and
git merge localbranch
to work on it, then you can
git push localbranch private
to put it into your private repo
Upvotes: 1