How do I use 'git rebase -i' to rebase all changes in a branch?

后端 未结 8 1376
Happy的楠姐
Happy的楠姐 2020-12-12 20:36

Here\'s an example:

>git status
# On branch master
nothing to commit (working directory clean)
>git checkout -b test-branch
>vi test.c
>git add t         


        
8条回答
  •  孤街浪徒
    2020-12-12 20:59

    A general solution (if you don't know the name of the upstream branch) is:

    git rebase -i @{upstream}
    

    Note that if your upstream (probably a tracking branch) has updated since you last rebased, you will pull in new commits from the upstream. If you don't want to pull in new commits, use

    git rebase -i `git merge-base --all HEAD @{upstream}`
    

    but that is a bit of a mouthful.

提交回复
热议问题