I've just started working with Git and I'm trying to figure out the best workflow for maintaining a forked repository and committing changes upstream via pull requests on Github.
I've been reading for a while, but haven't figure out the best practice. Let's use this one specific example, but this is a general workflow question.
Similar to the suggestion at Git workflow: forking a project and maintaing a local modified copy, but keep up to date, I've created a fork of magiclabs/alchemy_cms (upstream), off the 3.0-stable branch and then created another branch based off 3.0-stable to hold all custom changes. Let's call that branch custom.
Now the question is, when I want to make a new change and commit it back to the upstream magiclabs/alchemy_cms repo, what's the best way to do that so that I can create a pull request to merge to master AND also start to use that commit in the custom branch immediately. The PR may not be merged immediately, might needs changes, or might not be accepted.
What I've been doing is creating a feature branch off of master in the forked repo to get a clean pull request to submit upstream. Once I submit the pull request, I git cherry-pick
that commit to get it into the custom branch.
This seems unclean since it creates a duplicate commit hash and I'm not sure what will happen when the pull request is accepted.
Is there a better way to do this?
What I've been doing [to contribute to upstream] is creating a feature branch off of master in the forked repo to get a clean pull request to submit upstream. Once I submit the pull request, I git cherry-pick that commit to get it into the custom branch.
This is the correct way to do this. I manage projects on "custom" branches this way. When you periodically merge the upstream branch, it'll have 2 commits for the same operation... no big deal.
If your PR had to be reworked and no longer matches, you'll have a conflict at merge time, but that's an unavoidable cost of sailing ahead in a direction unapproved by the project leaders.
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句