简体   繁体   English

将更改从fork拉到Git中的原始存储库

[英]pull changes from fork to original repository in Git

I'm trying to learn Git. 我正在尝试学习Git。 I got a problem like this... I created a repository 'resorceplan' in GitHub. 我遇到这样的问题...我在GitHub中创建了存储库“ resorceplan”。 My colleague forked it and added new features to it. 我的同事为它添加了分叉并添加了新功能。 Now, he is not available in to push those changes to original repository 'resourceplan'. 现在,他无法将这些更改推送到原始存储库“ resourceplan”。 Is there any way that I can pull those new features into original repository ? 有什么办法可以将这些新功能拉到原始存储库中?

Any help will be appreciated ! 任何帮助将不胜感激 !

Thanks. 谢谢。

Assuming you can read/access the other person's repository - yes, you can. 假设您可以读取/访问其他人的存储库-是的,可以。 There are several ways to do so, for example: 有几种方法可以这样做,例如:

Add a remote, and pull/fetch from it 添加一个遥控器,并从中拉取/获取

Add a remote for the other user, merge in the changes and then push to your own repository: 为其他用户添加一个远程,合并更改,然后推送到您自己的存储库:

cd /my/repo
git checkout master
git remote add otheruser https://github.com/otheruser/repo.git
git fetch otheruser
git merge otheruser/branch

Treat as a "manual" pull request 视为“手动”拉取请求

Github has a help page demonstrating how to do this: Github有一个帮助页面,说明如何执行此操作:

cd /my/repo
git checkout master
git pull https://github.com/otheruser/repo.git branchname
git push origin master

Both of the above do the same thing - retrieve the branch history from a different repository and add the new commits to your own local repository (from there - just git push to update your own remote repository). 上面两者都做同样的事情-从不同的存储库中检索分支历史记录,并将新提交添加到您自己的本地存储库中(从那里-只需git push即可更新您自己的远程存储库)。

You should add your colleague as a collaborator, with the proper rights for pushing to your repo. 您应该将您的同事添加为协作者,并具有推送到您的仓库的适当权利。

在此处输入图片说明

You can find documentation about it here: https://help.github.com/articles/what-are-the-different-access-permissions 您可以在这里找到有关它的文档: https : //help.github.com/articles/what-are-the-different-access-permissions

Unless your colleague has admin privileges to your git repository, they will not be able to push directly to it. 除非您的同事对您的git存储库具有管理特权,否则他们将无法直接将其推送到该存储库。

The typical github contribution cycle is to fork the repository, create a branch for your change, commit the change to the forked repository and then to create a pull request to have the changes accepted upstream. 典型的github贡献周期是派生存储库,为您的更改创建分支,将更改提交到派生存储库,然后创建拉取请求以使更改在上游被接受。

If you add your colleague as an administrator to the repository, forking it is unnecessary since they can create their own branch and work off of it. 如果将您的同事作为管理员添加到存储库中,则无需进行分叉,因为他们可以创建自己的分支并使用该分支。

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

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