如何共享基于同一个存储库的git分支? [英] How to share git branches that are based on same repository?

查看:130
本文介绍了如何共享基于同一个存储库的git分支?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新手程序员,对GitHub来说是全新的。我正与一位同事一起合作多年来一直致力于他的项目。

I am a novice programmer, and completely new to GitHub. I am collaborating with a colleague on a project he has been working on over the years.

到目前为止:

他创建了一个存储库并加载了所有的初始文件。我将它分成我的帐户,以便我可以单独处理它。

He created a repository and loaded up all the initial files. I forked it into my account, so that I could work on it separately.

现在:

我如何提交我的存储库并与他分享,这样他可以检查出所做的更改并将它们整合到他的存储库中如果他喜欢这些更改吗?

How can I make a commit to my repository and share it with him, so that he can check out the changes and incorporate them into his repository IF he likes the changes?

我知道GitHub上有很多信息,但我甚至不确定从哪儿开始。任何帮助都非常感谢。

I know there is a lot of information on GitHub, but I'm not even sure where to start. Any help is greatly appreciated.

推荐答案

有很多方法可以做到这一点,github推荐pull请求,除非你没有push访问到版本库,您需要执行此操作或发送补丁程序。有一个这样的工作流程的例子此处

There are many ways to do this, github recommends pull requests and unless you have no push access to the repository you will need to do this or send patches. There is an example of such a workflow here

git clone git@github.com:<their repo> [optional folder name]
cd reponame (or optional folder name)

子模块然后

If the repository has submodules then

git submodule update --init (if the repo has submodules)
git submodule foreach 'git checkout <their working branch>'

分支代码。分叉您计划工作的特定存储库。这会给你你自己的项目副本。

Fork the code. Fork the specific repository you plan to work on. This will give you your own copy of the project. Set up git in the repository you plan to work on.

cd <repo dir or optional one chosen)
git remote set-url origin git@github.com:<your github name>/<your repo>.git
git remote add --track next upstream git://github.com/<their github name>/<their repo>.git

这是您的存储库设置的代码帮助。你可以做git pull,git push等(这将是/从你的叉子)。要从合作伙伴回购的分支中获取更改,请执行以下操作:

That is your repository set up to help with code. You can do git pull, git push, etc. (this will be to/from your fork). To pull in changes from a branch of the partner repo, just do:

git pull upstream branch

您无法将git推送至其回购站,因为您需要执行回覆请求。

You will not be able to git push to their repo, for that you need to do a pull request.

当你高兴的时候,转到github(你的项目)并选择diff和pull request。这允许您输入消息,并且lib维护者将收到一条消息来处理请求。它还会显示您的pull请求是否会干净地合并,如果维护人员必须修复代码,则不太可能被接受。

When you are happy then go to github (your project) and select diff and pull request. This allows you to put in a message and the lib maintainer will get a message to attend to the request. It will also show if your pull request will merge cleanly, it is unlikely to be accepted if the maintainer has to fix code.

这篇关于如何共享基于同一个存储库的git分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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