Git branch

1. What are branches

Branching is the use of simultaneous advancement of multiple tasks in version control.

As shown in figure:

2. Benefits of Git branches

  • Can develop multiple functions at the same time, improve development efficiency.
  • During the development of each branch, the failure of one branch has no impact on the other branches. Simply delete the failed branch and start again.

3. Git branch operations

  • Git branch -v

  • Git branch Specifies the new branch name used to create a new branch

  • Git checkout branch name

  • Merging branches: There are two steps

    • Step 1: Switch to the branch that you want to change. Git Checkout needs to accept the branch name
    • Step 2 Run git merge origin master
  • Resolve the conflict

    • The manifestation of conflict is shown in the following figure:

    • Conflict resolution:

      • Step 1: Edit the file and delete the special symbols
      • Step 2: Modify the file until you are satisfied, save and exit
      • Git add the file name
      • Git commit -m

Git branch management mechanism

1. Create a branch

Git branch Specifies the branch nameCopy the code

2. Switch branches

Git Checkout branch nameCopy the code
  • Two branches were created, currently pointing to hot_fix

  • Hot_fix has been updated with a new version,

  • The hot Fix branch is switched back to the Master branch

  • The master update