简体   繁体   English

我应该从Github派生一个小组项目还是在Eclipse中进行工作?

[英]Should I fork or pull a group project from Github to work on in Eclipse?

I am working a group project for school and I am new to Git and Github. 我正在为学校做一个小组项目,对Git和Github还是陌生的。 From what I understand about Github, when I 'fork' a repository I essentially create a copy of the project into my own Github account so that I can work on it independently. 据我对Github的了解,当我“分叉”存储库时,我实际上是在自己的Github帐户中创建项目的副本,以便我可以独立地进行工作。 I also understand I can pull directly from the original repository that my group member made into my IDE and go from there. 我也知道我可以直接从我的小组成员制作的原始存储库中提取到我的IDE中并从那里去。

If I 'fork' from my group member's repository, how do I update the fork with his changes if he were to make commits to it? 如果我从组成员的存储库中“分叉”,如果他要提交,我如何用他的更改来更新分叉?

I guess my question is: in a small group project where we have split up the work, is it a better idea to setup Eclipse to pull directly from the main repository so I can easily pull and merge changes into what I'm working on --OR-- fork the repository and work independently on my own copy, then somehow merge any changes my group members make into my own fork, then push my changes when I've complete my portion? 我想我的问题是:在一个小组项目中,我们将工作分开了,将Eclipse设置为直接从主存储库中提取是更好的主意,这样我就可以轻松地将更改合并并合并到我正在处理的工作中- -或-分叉存储库并在我自己的副本上独立工作,然后以某种方式将组成员所做的任何更改合并到我自己的分叉中,然后在完成工作后推送更改?

Is this a personal preference to pull from the original repository directly into Eclipse or to 'fork' the repository into my on Github account, then work from there? 这是个人喜好,是将原始存储库直接拉到Eclipse还是将存储库“分叉”到我的Github帐户上,然后从那里开始工作? Is it better practice to do one over the other? 更好的做法是彼此做一个吗?

I can probably figure out how to do it both ways via online tutorials, but I'm not sure which route to take. 我可能可以通过在线教程弄清楚如何做到这两种方式,但是我不确定该走哪条路。

All help is appreciated. 感谢所有帮助。

For small groups recommend using option 2 below and submitting changes on pull requests 对于小组,建议使用下面的选项2并根据拉取请求提交更改

Essentially two options: 本质上有两个选择:

  1. fork - read how to pull upstream changes here clone w/ pull. fork- 在此处阅读如何获取上游更改的克隆。 This approach is used when the project owners want to have control of how changes enter into the project. 当项目所有者希望控制更改如何进入项目时,可以使用这种方法。 For a class project that's probably not necessary. 对于班级项目,这可能不是必需的。
  2. clone - use feature branches & pull requests to manage changes (few more details below) 克隆-使用功能分支和拉取请求来管理更改(以下更多详细信息)

A git workflow for a small team might look like the following. 小型团队的git工作流程可能如下所示。 You can read more details here 您可以在此处阅读更多详细信息

  • clone the team repo to your local workstation 将团队存储库克隆到本地工作站
  • pick a feature to work on and create a branch to work on the feature 选择要使用的功能并创建要使用该功能的分支
  • make lots of messy commits until you have something ready to send to the team repo 进行许多混乱的提交,直到您有准备发送给团队仓库的东西为止
  • pull down upstream changes from the team that get committed to master and rebase your feature branch to incorporate those as needed 从团队中撤出上游变更,以致力于掌握并重新构建功能分支以根据需要合并这些变更
  • rewrite your commit history with git rebase -i origin/master git rebase -i origin/master重写提交历史
  • create a pull request to be merged into master 创建一个合并到主服务器的请求请求

The way we work on stuff and work, and thus the way I would work on it for personal projects is as follows: 我们在工作和工作上的工作方式以及我在个人项目中的工作方式如下:

  • Clone the main repository (no fork). 克隆主存储库(无分支)。

  • Checkout a new branch where you are planning to do all of your work. 签出一个新分支,您计划在其中完成所有工作。

  • When you're done checkout the main project branch (probably master, at work we use develop) 完成结帐后,主项目分支(可能是主项目,在工作中我们使用开发)

  • Run a git pull origin master (or whatever the main branch name is) 运行git pull origin master(或其他主要分支名称)

  • Checkout back to the branch you made all of your changes to. 签出返回所做的所有更改的分支。

  • On your branch run a git rebase master, this will run all of your changes on top of whatever is on master. 在您的分支上运行git rebase master,这将在master上运行所有更改。

  • Then do a git push origin 'your new branch name' 然后执行git push origin'您的新分支名称'

  • And finally, once the branch has been pushed to the main repo, submit a pull request. 最后,将分支推送到主仓库后,提交拉取请求。

This is a great way to keep a linear set of changes, and it works very well. 这是保持线性变化的一种好方法,并且效果很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM