git fork如何工作? [英] How git forking works?

查看:56
本文介绍了git fork如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我在github上签了名,并且我创建了一个项目.我的分叉存储库会在每次原始存储库更新时得到更新吗?还是应该每次都从原始存储库中进行分叉,以免丢失对原始存储库的任何新更改?

So I am signed in github and I fork a project . Will my forked repo get updated everytime the original repo updates ? Or should I do forking from the original repo everytime so I don't miss any new changes made to the original repository ?

推荐答案

fork是存储库的副本.分叉存储库使您可以自由地进行更改试验,而不会影响原始项目.

A fork is a copy of a repository. Forking a repository allows you to freely experiment with changes without affecting the original project.

没有,您的派生不会每次都自动更新,并且您不能多次派生一个存储库.如果需要,您必须删除prev fork并重新分叉存储库.

No your fork won't be updated automatically everytime and you can't fork a repository more than once. If you want, you'll have to delete the prev fork and refork the repo.

要使叉子保持原始状态,请执行以下步骤:

To keep your fork updated with original one you can follow below steps:

首先将原始存储库添加为本地分叉存储库中的远程上游:

first add the original repo as a remote upstream in your local forked one:

git remote add upstream [upstream.git]

现在,您可以轻松地将分支的(原始)存储库与上游存储库进行同步

Now, you can easily syncronize your forked (origin) repository with the upstream one by doing

git checkout master # Make sure you always run the following commands from the master branch
git fetch --all
git pull --rebase upstream master
git push origin master

这将对本地分叉版本的上游更改进行变基,因此, master 分支的git历史记录最后将完全相同.

This will rebase the upstream changes on your local forked version so the master branch git history will look exactly the same at the end.

从原始存储库中提取:

git pull upstream master  # you will get the original repo's update

并从分叉的那一个拉出:

and to pull from the forked one:

git pull origin master

这篇关于git fork如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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