search

Home  >  Q&A  >  body text

gitlab - How does git merge only the code records submitted by someone to the master branch?

Three people develop together (for example, A, B, and C), and then submit the code to the develop branch. Now that the project is going online, all the codes submitted by A on the develop branch need to be merged into the mater branch, B, and C. Regardless of the submitted code, how to implement this?

学习ing学习ing2782 days ago2308

reply all(6)I'll reply

  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-06-21 10:13:39

    First of all, I have to say that this development process is problematic.

    If ABC develops independent functions separately, then they should use their own branches. In this way, it is very convenient to manage and maintain, and there will be no such strange problems.

    Then, how to satisfy your strange needs:

    1. Use git log --author=... --format='%H' commit-range to find out the commit number

    2. Then pipe to the rev command in reverse order, then loop through it, and git cherry-pick the commits one by one to your master branch

    There is no reward, and I am too lazy to write specific orders. After all, the complete command must be tested and feasible by yourself. The test environment is too troublesome to set up. Check out the documentation and try it yourself.

    reply
    0
  • 为情所困

    为情所困2017-06-21 10:13:39

    Since they are jointly submitted to the develop branch, A will definitely pull the code of B and C, and merge can push it. How to separate them after they are turned into a bottle of water?
    The only way is to look at logs and diffs and separate them manually.

    reply
    0
  • 巴扎黑

    巴扎黑2017-06-21 10:13:39

    Since ABC has been submitted and merged into develop, there is no way to distinguish ABC, right? If it is determined that there is no problem with A's code, can we directly submit the code that needs to be merged in branch A to master?

    reply
    0
  • 阿神

    阿神2017-06-21 10:13:39

    1. Clone the project from the remote warehouse and put it in the local warehouse.
    2. Create a new branch on the master branch of this file with the same name as the A branch in the remote warehouse. If you are using Git, it is recommended to use checkout -b 'A branch name': create and directly enter this branch.
    3. In this new branch, pull branch A from the remote warehouse and submit it to the local warehouse.
    4. Switch to the master branch, merge the newly created branch, and then submit.

    reply
    0
  • 習慣沉默

    習慣沉默2017-06-21 10:13:39

    There may be two specific implementations of this kind:

    1. That is, you pull branches locally for development, and then merge them directly from the local to the master without going through the develop branch (but this should not be used). In this way, you need to ensure that your local code is consistent with the develop one

    2. The other option is that B and C can only remove their own code lines and then merge them

    Finally, I think this kind of git operation may still need to be analyzed based on your business and development model, so the answer obtained above may not necessarily conform to your development specifications.

    reply
    0
  • PHP中文网

    PHP中文网2017-06-21 10:13:39

    1. If A is cut branch and merged into dev after development, you can merge the code in the development branch in master (if develop does not want BC code, you can roll back the original uncommitted version number, merge A code again, and then master Merge)
    2. If A is local developmentsubmit to dev directly. If there are not many submissions, you can also directly cherryPick the entries submitted by A in the master by viewing the log

    reply
    0
  • Cancelreply