Git Rebase
git rebase [
git wiil go to another branch
by command git checkout
firstly and then apply the commits on it to
area.
We wiil start with the example showed in the last article Git Diff Different Branches
git checkout master
git rebase master dev
After resolving the conflicts in the rebase process, we got the following worktree.
git checkout master
git rebase dev
We can get the executive defails of the above two git commands by git reflog
2859ada (HEAD -> master) HEAD@{0}: rebase finished: returning to refs/heads/master
2859ada (HEAD -> master) HEAD@{1}: rebase: add func2
c0162bc (dev) HEAD@{2}: rebase: checkout dev
b794ebf HEAD@{3}: checkout: moving from dev to master
Step 1, go to branch master, we mark it current branch - master
Step 2, checkout branch dev
Step 3, apply the commits of current branch - master
to dev, then the pointer points to branch master.
Git Merge
Git provides merge command to combine both branch and create a new commit for the intersection on worktree.
git checkout master
git merge dev