git rebase

 

 how to use rebase?

    

     1) melt commits into one

         git  rebase –i HEAD~2

        git rebase -i 25b19f9d0 b78e055aa

        commit前开后闭

     

2) Copy commits to another branch

Execute on destination branch or need git reset –hard [endpoint] after switch to destination branch:

    git rebase [startpoint] [endpoint] --onto [branchName]

    Contains endpoint but dosn't contain startpoint

3) Merge branch and make commit logs graph tidier.

a)       git checkout –b <new_branch> # modify and commit

b)      git checkout master; git pull  #fetch latest code of master

c)       git checkout <new_branch>

d)      git rebase master # Here will merge master latest codes and modification

e)       git checkout master; git merge <new_branch>

f)        push to origin remote repository if need

 

reference link: http://jartto.wang/2018/12/11/git-rebase

posted @ 2020-12-08 16:57  i舒  阅读(136)  评论(0编辑  收藏  举报