git Git从别人的叉子拉
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42156971/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git pull from someone else's fork
提问by M.A.B
We are two students working on our online repository (different repo) that is forked from a common upstream repo.
我们是两个学生,在我们的在线存储库(不同的存储库)上工作,该存储库是从一个常见的上游存储库分叉出来的。
Let's say other student made Changes, Commits and Pushed to his repo on a specific branch.
假设其他学生在特定分支上对他的 repo 进行了更改、提交和推送。
How do I pull these changes into my own local repository?
Do I need to commit and push those changes to my staged area?
如何将这些更改拉入我自己的本地存储库?
我是否需要提交并将这些更改推送到我的暂存区?
Thank you!
谢谢!
回答by Sajib Khan
Simply add a new remote (say, other
) in your own
repo. Then Pull other/<branch>
changes into your local branch (say, add-other-changes
). Push to your own forked repo (origin/add-other-changes
). Now, when you done with add-other-changes
branch, create a Pull request & merge with origin/master
.
只需other
在您的存储own
库中添加一个新的遥控器(例如,)。然后将other/<branch>
更改拉入您的本地分支(例如,add-other-changes
)。推送到您自己的分叉存储库 ( origin/add-other-changes
)。现在,当您完成add-other-changes
分支后,创建一个 Pull 请求并与origin/master
.
Pull other repo's changes into your own repo:
# go into your own repo $ git remote add other <other-student-repo-url> # add a new remote with other's repo URL $ git fetch other # sync/update local with other's repo $ git checkout -b add-other-changes # create a new branch named 'add-other-changes' $ git pull other <specific-branch-name> # pull other/<branch> changes $ git push origin HEAD # push changes to your own(origin) forked repo `add-other-changes` branch
将其他 repo 的更改拉到您自己的 repo 中:
# go into your own repo $ git remote add other <other-student-repo-url> # add a new remote with other's repo URL $ git fetch other # sync/update local with other's repo $ git checkout -b add-other-changes # create a new branch named 'add-other-changes' $ git pull other <specific-branch-name> # pull other/<branch> changes $ git push origin HEAD # push changes to your own(origin) forked repo `add-other-changes` branch
回答by bilpor
commit and push your working branch. Then do a merge from the main branch to your branch. Ensure all build and resolve any conflicts. commit and push your branch. Now merge your branch into the main branch and it should work.
提交并推送您的工作分支。然后从主分支合并到你的分支。确保所有构建并解决任何冲突。提交并推送您的分支。现在将您的分支合并到主分支,它应该可以工作。
回答by smarber
If you both want to work on the same project, then you shouldn't have forked the the repository twice. You or you friend (not both) should fork the repository, then both of you should clone the forked one in local (permissions need to be granted by the one who forked repository).
如果你们都想在同一个项目上工作,那么你不应该两次分叉存储库。您或您的朋友(不是两者)应该分叉存储库,然后你们都应该在本地克隆分叉的存储库(需要由分叉存储库的人授予权限)。
Once this is done, when members of the project want to know if there are new changes on the remote, they can do git remote update
or more commonly git fetch origin
.
完成此操作后,当项目成员想知道远程是否有新更改时,他们可以执行git remote update
或更常见的git fetch origin
.
If you're working on the same branch and you want to update your local branch with the remote one git pull origin <branh_name>
如果您在同一个分支上工作并且想用远程分支更新本地分支 git pull origin <branh_name>
If one have made changes that should get shared:
如果有人做出了应该共享的更改:
git add file_path_1 file_path_2 directory_path1 ...
git commit -m "<your brief message>"
git push origin <branch_name>