正在学习使用git,貌似git分支在合并的时候,比如将dev分支合并到master分支上,master的当前版本是m1,如果dev分支上有了d1,d2,d3三个新版本,合并时候,会将d1,d2,d3三个版本都添加到master的版本中去。
能不能只将开发的最终版本合并到master中呢?
我现在能想到的是git merge dev后,在master分支中git reset --soft 到m1版本,然后再commit成新版本。
有没有更直接的方法或者指令,合并时候只将最终版本合并到master中?
还是说,应该在merge前,在dev分支中就应该git reset --soft到dev分支最初版本,commit城新版本再合并?
请问实际工作中,应该怎么操作啊。
cherry-pick
You can pull and load content from other branches instead of merging commits.However, it is not recommended to use this. Because this will lose the meaning of using version control.
git cherry-pick <start-commit-id>..<end-commit-id>
git cherry-pick can merge certain commits from different branches