How do I merge branches using git rebase?

both git merge and git rebase can be used to merge branches. Merge is to merge commit into a new commit

. The operation of

git rebase is also merging. For example, I want to merge the A branch into the master branch. The merge operation is as follows:
switch to the master branch first: execute git merge A
use rebase:
switch to the A branch first: git rebase master, this operation is to change the A branch commit base point connected to the end of the master. Then switch to the master branch to execute git merge A. Then the commit records you see after git log are all on the same line and will not bifurcate.

there is a great god said not to execute on the master branch when executing rebase, because it will cause the loss of commit, but I still have to perform a merge operation on master after performing rebase on branch A, isn"t that one more step compared to merge? Just to check the log records to look better?

maybe the problem is not expressed very well, please give me some advice on the operation of rebase!

Git
Apr.06,2021

my understanding is this:

  1. pull A branch from master
  2. develop and submit multiple commit on A
  3. when master has a new commit , use rebase to combine master's new commit in A, and make sure that the new commit added in A will be at the end of log. This operation can be used multiple times during A's development phase.
  4. A development is completed. Merging A with mergin on master will not automatically generate 'commit'
  5. for merging branches.
Menu