git 将远程 github 存储库中的更改合并到本地存储库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/867831/
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
Merge changes from remote github repository to your local repository
提问by ?eljko Filipin
I have forked a repository on github some time ago, made a small change and pushed the change back to my github fork. The original repository has changed since. I would like to merge the changes from the original repository to my fork.
前段时间我在 github 上 fork 了一个仓库,做了一个小改动,把改动推回了我的 github fork。从那以后,原始存储库发生了变化。我想将原始存储库中的更改合并到我的 fork。
I am new to both git and github, and I need specific commands how to do it.
我是 git 和 github 的新手,我需要具体的命令来做这件事。
回答by ?eljko Filipin
git remote add {name} {Public Clone URL}
git pull {name} master
git push
Example:
例子:
git remote add bret git://github.com/bret/watir.git
git pull bret master
git push
回答by Marcin Gil
Simply add original repo as a remote and merge your fork with it; then push merged fork to github.
只需将原始 repo 添加为远程并将您的 fork 与其合并;然后将合并的 fork 推送到 github。
There's also a ruby gem for easier github operations. You can merge upstream with one call...
还有一个ruby gem 可以简化 github 操作。您可以通过一次呼叫合并上游...
回答by fat
回答by Val
git pull origin master
will do the job creating additional merge commit. If you do not have conflicts and do not want to create a rejoin (with additional 'merge' commit) for every commit that you push then rebase
is more preferred. You can do it with the Git Gui+gitk. Just fetch remote with Git Gui
then open history with gitk
and create temporary r_master
branch at remotes/origin/master
fetched. Finally, call git rebase r_master
in the git bash
. This will place your commits on top of the remote modifications. You are ready to push and remove the r_master
.
将完成创建额外合并提交的工作。如果您没有冲突并且不想为您推送的每个提交创建重新加入(带有额外的“合并”提交),那么rebase
更优选。你可以用 Git Gui+gitk 来完成。只需获取远程,Git Gui
然后打开历史记录gitk
并r_master
在remotes/origin/master
获取时创建临时分支。最后,调用git rebase r_master
的git bash
。这会将您的提交置于远程修改之上。您已准备好推送和删除r_master
.
This commentsuggests that there are shortcuts for this flow.
此评论表明此流程有捷径。