Git merge git rebase

The goal is to merge a COMMIT from one branch into another

git merge

  1. Create a new project in GitLab and push a test file to it

2. Modify the test file locally and make a commit twice. Each commit adds a change to the file

3. Modify files directly in the remote repository and commit, simulating the commit of other developers

Git fetch = git fetch + git merge

Come into conflict:

Handling conflict:

Redo add commit and then push, and you can see that the merge must be treated as a new COMMIT:

git rebase

Git fetch =git fetch + git rebase

  1. Same as local commit2, remote COMMIT2

  1. Using git pull –rebase, we are still prompted to handle the conflict, but it is clear from the Git log that a rebase has taken place. The local branch is based on the latest remote commit, not the last local commit

  1. Git rebase –continue git rebase — git rebase -i git rebase -i git rebase -i git rebase -i git rebase -i git rebase -i Git pull –rebase can handle all conflicts at once

  1. After pushing to a remote, you can clearly see in the branching diagram that, unlike merge, rebase does not branch and does not generate new commits