How does Git upload its own local branch code to a remote master branch

Git git:

  • Commit: Commit code to the local repository.
  • Pull: Synchronizes remote repository code to local repository. If there are conflicts, resolve them and repeat commit->pull until there are no conflicts.
  • Push: Commits local repository code to a remote repository.

Upload your own local branch code to the remote main branch, involving four parts

  • Local slave branch
  • Remote slave branch
  • Local landlord branch
  • Remote main branch

The code update process can also be understood as: remote master branch -> local slave branch -> Remote slave branch -> local master branch -> Remote master branch

Step 1: Pull the latest main branch code from the remote main branch into your own local branch.

Take IDEA as an example: Click VC-git-pull to pop up the following popup window, then check the main branch and click Pull to Pull the main branch code (if there is a conflict, the code needs to be modified)

Step 2: Commit the locally changed code to the local repository and then push it to a branch on your remote.

Take IDEA as an example: Click VC-Commit and the following pop-up window pops up. Then check the code to be committed and click Commit

Take IDEA as an example: Click VC-Git-push to pop up the following popup window, and then select the branch on the remote. Click the Push button to pop up the branch on the remote as shown in Figure 2, indicating that the branch has been successfully submitted to the remote.

Step 3: Switch to the local branch, compare it with the remote branch, and Merge the remote branch into the local branch

Then switch to the main branch master as shown in the picture, locate your branch on Remote Branches, click the triangle icon in the expanded list and select “Merge into Current”.

Step 4: Push the merged local master branch code to the remote master branch

Take IDEA as an example: Click VC-Git-push and the following pop-up window pops up