Idea + git merge branch to resolve conflicts and detailed steps

Time:2020-10-28

Git branch details reference:

Branch management composition

1.1. Master trunk

In version management, the code base should have only one trunk. This trunk is consistent with the current production. It is available, stable and can be released directly. No development operation can be carried out on the trunk. The name of GIT trunk is called master by default. It is created automatically.

1.2. Main development branch of development

Because you can’t develop on the trunk master, you need to create a development main branch development based on the trunk master. The code of developing the main branch development is always up-to-date. All new functions are developed on the basis of this branch. The branch is only for merging operation, and it can not be developed in this branch.

1.3 feature function development branch

The function development branch is created on development. The naming standard of “feature -” + “branch creation time” + “batch name -” is adopted.
For example: “feature-20190301-xxx”
This branch is not only a requirement development branch, but also a requirement test branch. All the content that needs to be online can be submitted to merge with other branches to be launched after the current branch has passed the full test, and then the test branch regression test is conducted.

1.4 test branch

The test branch refers to that before the official version is released (that is, before merging into the master branch), we need to have a pre release version for testing.
The pre release branch is separated from the development branch. The pre release deployment production verification is correct. After the completion, the master and development branches must be merged downward, and all development branches derived from development must be merged to ensure that the baseline version of each branch is synchronized with the production baseline.

1.5 hotfix emergency bug branch

After the project goes online, there will be some bugs that need to be repaired urgently. Therefore, it is necessary to create an emergency bug modification branch. This branch needs to pull the branch directly from the master for development modification. After the repair is completed, it must be merged into the master and development branches and all the branches derived from development to ensure that the baseline version of each branch is synchronized with the production baseline.
use
“Hotfix -” + “branch creation time” + “bug number or bug description”.
For example: “hotfix-20190116-001”

1. Switch branches

1) Click the branch name in the lower right corner of the idea page

2) Select the item in the GIT branch selection box and select the branch you want step by step

Here, we first demonstrate the switch to the main branch of the master, and click checkout to switch

3) Switch the master trunk branch successfully

2. Merge branches

1) Master merge bug001 branch

2.1.1. Take branch steps: right click on the item,Git -> Repository -> Pull

2.1.2. When updating the code, select the 001 branch code, merge it into the current branch master, and click pull

2.1.3. The update result shows that 37 files have been updated

2.1.4. After updating the code from branch 001 to the master branch of the current branch, it has been stored in the local warehouse. Therefore, it is necessary to push the complete master branch code of the local warehouse to the master branch of the remote branch;Git -> Repository -> Push

2.1.5. After clicking push, the detailed push instructions will appear. Click push

2) Develop merge master branch

2.2.1 switch the development branch. In principle, the code of the development branch must be consistent with the master trunk

2.2.2. Pull branch steps: right click the item name,Git -> Repository -> Pull, reference 2.1.1
First, update the remote development branch to the local to see if there is any code that needs to be updated. If some, update it directly

2.2.3. Display no items, indicating that there is no code to be updated

2.2.4 the master branch is up-to-date, so it is necessary to merge the master branch code into the development branch
Git -> Repository -> Pull, select the master branch code, merge it into the current branch development, and click pull

The result is 37 files

2.2.5. Submit the code of the local warehouse development branch to the remote branch development; git > repository > push

Show push success

3) Hebei merge development branch

2.3.1. Switch Hebei Branch

Switch succeeded

2.3.2 update the branch code and pull the branch steps: right click on the project name, GIT > repository > pull, refer to 2.1.1

2.3.3 merge the development branch code into the current branch Hebei;Git -> Repository -> Pull

2.3.4. Conflict file appears during update (20200604 update, the content is the latest, which is inconsistent with the above development branch content)
Conflict resolution:
Select the file and click merge on the right

2.3.5. Interface interpretation of conflict file
The conflict file interface is divided into three parts: the left side is the local code; the middle is the final result file after conflict resolution; and the far right side is the code of remote branch
By comparing the file content, merge the required code to the middle position, and finally click apply to complete

The solution steps are as follows:

The result of the update is 5 files, including one file after conflict resolution

2.3.6. Because there is a conflict when merging the development branch code to the current branch Hebei, and after the conflict is resolved, the code needs to be submitted to the local warehouse first, and then the code of the local warehouse is submitted to the remote branch.

Right click the project name:
Git-> Commit Directory…

Fill in the appropriate submission information and clickCommit and Push

Commit and PushExplanation:
First submit the local code to the local warehouse, and then wait for a moment to automatically pop up the push window, and then push the local warehouse code to the remote

2.3.7 view the submission information and click push to submit the code to the remote branch.

This article on the idea + git merge branch conflict resolution and detailed steps of the article introduced here, more related idea git merge branch to solve the conflict content, please search the previous articles of developpaer or continue to browse the related articles below, I hope you can support developeppaer more in the future!