what is the difference between git pull , git fetch and git rebase?
This question already has an answer here:
Fetch: update local with remote changes but not merge with any local branch .
Pull: update local and merge the changes with current-branch .
git fetch : Get the latest changes from origin (no merge)
git pull = git fetch + git merge
If you rebase feature branch onto master branch. git rebase master , it would keep the feature branch commits/changes top.
Say you have two commits in master branch ( A -> C ) and two commits in feature branch ( B -> D ).
Assume you are in feature branch ( git checkout feature ). Now if you merge master then commit history:
(previous commit) - A -- C <- master
B -- D -- M <- feature
Here, M for new-merge-commit-sha .
For rebase master , commit history: ( A -> C -> B' -> D' ).
上一篇: 在Git中只提取未更改的文件
