This is the 14th day of my participation in the August More Text Challenge. For details, see:August is more challenging

Create a new branch

  1. Git Branch bugFix Creates a new branch
  2. Git Checkout bugFix switch to the new branch

1. Branch and merge

  • We’re going to merge the bugFix into main
  • Main now points to a commit record with two parents. If you follow the arrow up from main, you will pass through all the commit records on your way to the starting point. This means that Main contains all changes to the code base
  1. Git branch bugFix – Create a branch
  2. Git checkout bugFix – Switch to this branch
  3. Git commit – Commit once
  4. Git checkout main – Switch to the main branch
  5. Git commit – Commit again
  6. Git merge bugFix – Merge bugFix into main

2. Branch and merge

  • The second way to merge branches is git Rebase.
  • Rebase is essentially taking a list of commit records, “copying” them, and dropping them one by one in another place.

  • The commit record C3 still exists (the translucent node on the tree), and C3′ is a copy of C3 that we Rebase to the main branch.

  • Now we switch to main. Rebase it to the bugFix branch
Git commit git ch## create a branchCopy the code

2. Git checkout bugFix switch to new branch

! [](https://img2020.cnblogs.com/blog/1909820/202104/1909820-20210429080140531-1225981382.png) ## 1. Branch and Merge - ** we're going to merge bugFix into main ** -main now points to a commit record with two parents. If you follow the arrow up from main, you will pass through all the commit records on your way to the starting point. This means that Main contains all changes to the code baseCopy the code
Git branch commit = git branch commit = git branch commit = git branch commit = git branch commit = git branch commit Merge bugFix - Merges bugFix into mainCopy the code

2. Branch and merge

  • The second way to merge branches is git Rebase.
  • Rebase is essentially taking a list of commit records, “copying” them, and dropping them one by one in another place.

  • The commit record C3 still exists (the translucent node on the tree), and C3′ is a copy of C3 that we Rebase to the main branch.

  • Now we switch to main. Rebase it to the bugFix branch
Git branch bugFix Create branch git checkout bugFix Switch branch git commit git checkout main Switch branch Git commit git rebase main Rebase on mainCopy the code