what is the difference between git pull , git fetch and git rebase?

This question already has an answer here:

  • What is the difference between 'git pull' and 'git fetch'? 40 answers

  • 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' ).

  • 链接地址: http://www.djcxy.com/p/1190.html

    上一篇: 在Git中只提取未更改的文件

    下一篇: git pull,git fetch和git rebase有什么区别?