Git工作流程:分叉项目并维护本地修改后的副本,但保持最新状态

问题描述:

我试图找出最佳的工作流程来维护自定义的github托管项目(moodle)的本地副本,同时保持我们的副本保持最新的能力。告诉我,我想要做的事完全是疯狂的:

I'm trying to figure out the best workflow for maintaining a local copy of a github-hosted project (moodle) with customizations, while maintaining the ability to keep our copy up-to-date. Tell me if what I'm thinking about doing is completely insane:


  1. 分叉项目(github.com/moodle/moodle - >
  2. 创建上游远程(git remote add upstream git://github.com/moodle/moodle.git&& git fetch上游)
  3. / li>
  4. 为我们的自定义开发创建一个分支并保持原始状态。

  5. 当我们想更新fork时,更新原始分支(git checkout master& amp ;&git fetch upstream&& git merge upstream / master)

  6. 将master融入我们的定制分支(git checkout custom&& git merge master) b $ b
  1. Fork the project (github.com/moodle/moodle --> github.com/sfu/moodle)
  2. Create an upstream remote (git remote add upstream git://github.com/moodle/moodle.git && git fetch upstream)
  3. Create a branch for our custom development and keep master pristine.
  4. When we want to update our fork, update the pristine branch (git checkout master && git fetch upstream && git merge upstream/master)
  5. Merge master into our customizations branch (git checkout custom && git merge master)

是否有意义?

这说得通。尽管步骤#4可以稍微简化为 git checkout master&& git pull - 仅限上游主人

Yes, it makes sense. Although step #4 can be slightly simplified to git checkout master && git pull --ff-only upstream master.

- 仅ff 确保您在原始副本中不会获得任何合并提交。

The --ff-only ensures that you don't get any merge commits in your pristine copy.