search

Home  >  Q&A  >  body text

How does git merge only the last version on the development branch to the master branch?

I am learning to use git. It seems that when git branches are merged, for example, the dev branch is merged into the master branch. The current version of master is m1. If there are three new versions of d1, d2, and d3 on the dev branch, merge them. At that time, all three versions of d1, d2, and d3 will be added to the master version.

Can I just merge the final version of development into master?

What I can think of now is that after git merge dev, git reset --soft in the master branch to the m1 version, and then commit to the new version.

Is there a more direct method or instruction to only merge the final version into master when merging?

Or should I git reset --soft the original version of the dev branch in the dev branch before merging, commit the new version, and then merge?

Please tell me how to operate it in actual work.

漂亮男人漂亮男人2882 days ago640

reply all(4)I'll reply

  • PHP中文网

    PHP中文网2017-05-02 09:42:30

    git checkout master
    git cherry-pick dev # 拿最后一个版本
    git cherry-pick dev~3..dev # 拿最新的3个版本

    reply
    0
  • 巴扎黑

    巴扎黑2017-05-02 09:42:30

    cherry-pickYou 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.

    reply
    0
  • ringa_lee

    ringa_lee2017-05-02 09:42:30

    git cherry-pick <start-commit-id>..<end-commit-id>

    reply
    0
  • 大家讲道理

    大家讲道理2017-05-02 09:42:30

    git cherry-pick can merge certain commits from different branches

    reply
    0
  • Cancelreply