How to merge previous commits
I've setup Gitlab and I'm trying to follow the workflow mentioned here: Gitlab Production branch flow.
Now my repository looks like this:
And I've been asked to merge only commit A
of the master
branch with the production
branch. What is the best way to do this?
Should I use the git cherry-pick
command? I read I'll loose the version history with the cherry-pick
.
If I've this situation where I need to keep merging one of the previous commits from master
branch to the production
branch, how do I handle this?
I'm stuck at this. Any help is greatly appreciated.
Thanks,
Update: From master branch I can push only specific commits: git push <remotename> <commit SHA>:<remotebranchname>
Found answer here: How can I push a specific commit to a remote, and not previous commits?
Cherry picking is viable if you specifically want the changes made in select commits. It's most beneficial when the commits you need to apply didn't occur in sequential order. Personally, I wouldn't recommend you do this on master/production branches as it's not a good long term release strategy.
My advice is based on git flow, which I know is somewhat different to GitLab's approach.
If these are actual releases, consider following a release branch workflow, where in this case you create a release branch on commit A
, and then merge into production.
If these are bugfix/hotfixes needing some commits but not all (requiring cherry-picking), you could create a hotfix branch from your production branch, cherry-pick the commit you need to that branch first, then when testing is finalized merge that back into production. If any extra changes or commits are applied in that branch they will need to be merged back into whatever your development branch is as well.
链接地址: http://www.djcxy.com/p/49816.html下一篇: 如何合并以前的提交