Git Rebase

git rebase [<upstream> [<branch>]]
git wiil go to another branch <branch> by command git checkout firstly and then apply the commits on it to <upstream> 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) [email protected]{0}: rebase finished: returning to refs/heads/master
2859ada (HEAD -> master) [email protected]{1}: rebase: add func2
c0162bc (dev) [email protected]{2}: rebase: checkout dev
b794ebf [email protected]{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



Categories: Tool


Leave a Reply

Your email address will not be published. Required fields are marked *

You cannot copy content of this page