我可以将 git 上的分叉项目更新为原始/主副本吗? [英] Can I update a forked project, on git, to the original/master copy?

查看:20
本文介绍了我可以将 git 上的分叉项目更新为原始/主副本吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几周前,我在 GitHub 上创建了一个公共项目.今天,我想尝试一些东西,但我想确保我使用的副本是最新的.

A few weeks ago i forked a public project on GitHub. Today, I wish to try some stuff on it BUT i want to make sure the copy I use is the most recent.

我可以先更新我的叉子吗?

Can I update my fork, first?

如果在我开始更改后叉子发生更改会发生什么.我可以再次更新我的 fork,同时保留我的更改(即合并,如果需要?)

And what happens if there's changes to the fork AFTER i've started my changes. Can i update my fork again, while leaving my changes in there (ie. merge, if needs be?)

推荐答案

是的,您可以pull 原始 repo 中的更改到您的 fork 中.添加一个遥控器(因为 origin 将是你的叉子)并拉动.

Yeah you can pull the changes from the original repo into your fork. Add a remote to it ( since origin will be your fork ) and pull.

这来自 GitHub 帮助:

This from GitHub help:

首先,向原始存储库添加一个遥控器.

First up, add a remote to the original repo.

这里的帮助:http://help.github.com/remotes/

然后您可以将更新拉入原始存储库.引用自 http://help.github.com/fork-a-repo/

Then you can pull in updates to the original repo. Quote from http://help.github.com/fork-a-repo/

引入上游变化

如果你从你的项目中分叉的原始仓库得到更新,你可以通过运行以下代码将这些更新添加到您的 fork:

If the original repo you forked your project from gets updated, you can add those updates to your fork by running the following code:

$ git fetch 上游

$ git fetch upstream

$ git merge 上游/主

$ git merge upstream/master

所有这些都是从命令行完成的.

All these are for doing from command line.

以下是 TortoiseGit 的说明:

右键单击您的项目 -> TortoiseGit -> 设置 -> 远程.

Right click over your project -> TortoiseGit -> Settings -> Remote.

在此处添加远程详细信息:

Add the remote details here:

现在,右键单击 -> TortoiseGit -> Pull.

Now, right-click -> TortoiseGit -> Pull.

您将看到一个对话框来选择遥控器(您应该能够看到您在上一步添加的遥控器).选择它并拉动.

You will be presented with a dialog to choose the remote ( you should be able to see the remote you added in previous step). Choose it and pull.

这篇关于我可以将 git 上的分叉项目更新为原始/主副本吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆