$ git checkout develop $ $ git rebase feature-a First, rewinding head to replay your work on top of it... Fast-forwarded develop to feature-a. $ $ git rebase feature-b First, rewinding head to replay your work on top of it... Applying: add feature_a.c
在上述指令中,我们先切换到develop分支中,接着我们很快的就利用指令git rebase合并了feature-a与feature-b。此外,在上述的指令执行结果中,可以看到一行讯息显示Fast-forwarded develop to feature-a,其中的Fast-forwarded是什么意思呢?
# Rebase 38844ba..d26076a onto 38844ba # # Commands: # p, pick = use commit # r, reword = use commit, but edit the commit message # e, edit = use commit, but stop for amending # s, squash = use commit, but meld into previous commit # f, fixup = like "squash", but discard this commit's log message # x, exec = run command (the rest of the line) using shell # # These lines can be re-ordered; they are executed from top to bottom. # # If you remove a line here THAT COMMIT WILL BE LOST. # # However, if you remove everything, the rebase will be aborted. # # Note that empty commits are commented out
# Rebase 38844ba..d26076a onto 38844ba # # Commands: # p, pick = use commit # r, reword = use commit, but edit the commit message # e, edit = use commit, but stop for amending # s, squash = use commit, but meld into previous commit # f, fixup = like "squash", but discard this commit's log message # x, exec = run command (the rest of the line) using shell # # These lines can be re-ordered; they are executed from top to bottom. # # If you remove a line here THAT COMMIT WILL BE LOST. # # However, if you remove everything, the rebase will be aborted. # # Note that empty commits are commented out
# Rebase 38844ba..d26076a onto 38844ba # # Commands: # p, pick = use commit # r, reword = use commit, but edit the commit message # e, edit = use commit, but stop for amending # s, squash = use commit, but meld into previous commit # f, fixup = like "squash", but discard this commit's log message # x, exec = run command (the rest of the line) using shell # # These lines can be re-ordered; they are executed from top to bottom. # # If you remove a line here THAT COMMIT WILL BE LOST. # # However, if you remove everything, the rebase will be aborted. # # Note that empty commits are commented out
接下来,如果用git status就可以看到我们正在rebase的讯息:
1 2 3 4 5 6 7
$ git status rebase in progress; onto 38844ba You are currently editing a commit while rebasing branch 'Feature-B' on '38844ba'. (use "git commit --amend" to amend the current commit) (use "git rebase --continue" once you are satisfied with your changes)