问题
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:
- Fork the project (github.com/moodle/moodle --> github.com/sfu/moodle)
- Create an upstream remote (git remote add upstream git://github.com/moodle/moodle.git && git fetch upstream)
- Create a branch for our custom development and keep master pristine.
- When we want to update our fork, update the pristine branch (git checkout master && git fetch upstream && git merge upstream/master)
- Merge master into our customizations branch (git checkout custom && git merge master)
Does this make sense?
回答1:
Yes, it makes sense. Although step #4 can be slightly simplified to git checkout master && git pull --ff-only upstream master
.
The --ff-only
ensures that you don't get any merge commits in your pristine copy.
回答2:
Makes sense
... and if you like, compare with bible :
a successful git branching model
来源:https://stackoverflow.com/questions/9386352/git-workflow-forking-a-project-and-maintaing-a-local-modified-copy-but-keep-up