git 更新 GitHub 上的分叉项目
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4936109/
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
Update forked project on GitHub
提问by ZeroSuf3r
Let's say a repository from which I clone (and only read-only for me) is:
假设我从中克隆的存储库(对我来说仅为只读)是:
[email protected]:secret_project/dev.git branch: dev
I forked project and URL:
我分叉了项目和 URL:
[email protected]:secret_user/Dde.git
(Which I have full access to: read+write)
(我可以完全访问:读+写)
But someone updated [email protected]:secret_project/dev.git
from another forked version.
但是有人[email protected]:secret_project/dev.git
从另一个分叉版本更新。
Let's say file changed on
假设文件已更改
[email protected]:secret_project/dev.git (test.txt)
content:
hi!
But my forked project has test.txt
file with content:
但是我的分叉项目有test.txt
包含内容的文件:
hi
So how do I update the forked project locally and in my repository?
那么如何在本地和我的存储库中更新分叉项目呢?
Which commands should I use? And please make an example with my showed repositories...
我应该使用哪些命令?请用我展示的存储库做一个例子......
采纳答案by VonC
You should add the remote address for the original repository 'upstream
' to your local repository (which is a clone of your Dde.git
fork):
您应该将原始存储库“ upstream
”的远程地址添加到您的本地存储库(它是您的Dde.git
fork的克隆):
git remote add upstream git://github.com/secret_project/dev.git # public read-only URL
That will allow you to pull 'upstream
' into your own branch (merging and resolving any merge conflict in test.txt
).
Then you will push your local branch to your Dde
GitHub repository.
这将允许您将“ upstream
”拉入您自己的分支(合并并解决 中的任何合并冲突test.txt
)。
然后,您将本地分支推送到您的Dde
GitHub 存储库。
See GitHub help page: "Working with remotes"for more details.
有关更多详细信息,请参阅GitHub 帮助页面:“使用遥控器”。
回答by pseudoCoder
Just send out a pull request from your repository's GitHub page to your Parent repository. Then pull the changes in your local forked repo and commit and send a fresh pull request.
只需从您的存储库的 GitHub 页面向您的父存储库发送拉取请求。然后拉取本地分叉仓库中的更改并提交并发送新的拉取请求。
回答by Krish Munot
The steps here will move your fork to the same commit as the parent repository:
此处的步骤会将您的 fork 移动到与父存储库相同的提交:
- Change directory to your local repository.
Switch to master branch if you are not and type this
git checkout master
- Add the parent as a remote repository,
git remote add upstream <repo-location>
- Issue
git fetch upstream
- Issue
git rebase upstream/master
At this stage you check that commits what will be merged by typinggit status
- Issue
git push origin master
- 将目录更改为本地存储库。如果不是,请切换到 master 分支并键入此
git checkout master
- 将父级添加为远程存储库,
git remote add upstream <repo-location>
- 问题
git fetch upstream
- 问题
git rebase upstream/master
在此阶段,您检查是否提交了将通过键入合并的内容git status
- 问题
git push origin master