简体   繁体   中英

Fork a github repo and push to my private repo

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM