简体   繁体   English

分叉一个github仓库并推送到我的私人仓库

[英]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. 我正在上一堂课,该课有一个全班级的github存储库,用于发布实验室,文档等。我想分叉,在实验室中做自己的工作,然后推送到我的私人git存储库。 However, I still want to be able to pull changes from the class github. 但是,我仍然希望能够从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. 是的,可以肯定的是,密钥在您的回购遥控器中,因此您的货叉有一个名为“ origin”的遥控器,并且对于原始回购创建了一个称为上游的遥控器。

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 换句话说,您可以直接在Github中创建拉取请求

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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