git rebase test2

准备工作完成

cyper@zerorun:~/gitosc/rebasetest$ git log --oneline
c400c0c first commit
cyper@zerorun:~/gitosc/rebasetest$


cyper下下来然后做两次提交:

git log --oneline
7d6929a cyper 2nd commit.
047e599 cyper 1st commit.
c400c0c first commit




gittest做两次提交并push到origin/master
cyper@zerorun:~/gitosc/rebasetest$ git log --oneline
227259c gittest commit 3.
1201ac9 gittest commit.
c400c0c first commit


cyper先fetch
git fetch
然后cyper可以查看origin/master上的历史

➜  rebasetest git:(master) $ git log origin/master --oneline
227259c gittest commit 3.
1201ac9 gittest commit.
c400c0c first commit


cyper然后做rebase

➜  rebasetest git:(master) $ git rebase origin/master
First, rewinding head to replay your work on top of it...
Applying: cyper 1st commit.
Applying: cyper 2nd commit.
➜  rebasetest git:(master) $


cyper做git status

➜  rebasetest git:(master) $ git status
On branch master
Your branch is ahead of 'origin/master' by 2 commits.
  (use "git push" to publish your local commits)
nothing to commit, working directory clean



cyper查看log, 可见rebase就是在本地分支的最前端插入了远程的提交。
➜  rebasetest git:(master) $ git log --oneline
e37af86 cyper 2nd commit.
a843ab8 cyper 1st commit.
227259c gittest commit 3.
1201ac9 gittest commit.
c400c0c first commit


最后cyper提交变更
git push origin master







你可能感兴趣的:(git rebase test2)