Git rebase
2019-03-14 本文已影响0人
JaedenKil
user@PC0T9SND MINGW64 /c/Projects/AS_Project/GitDemo (master)
$ git log --oneline
0e2d274 (HEAD -> master) Add file03
445cb1c (dev) Add file02
c3cab12 Add file01
user@PC0T9SND MINGW64 /c/Projects/AS_Project/GitDemo (dev)
$ git log --oneline
6b1bae9 (HEAD -> dev) Add file04
445cb1c Add file02
c3cab12 Add file01
Now I have a repo:
- Branch
master
: A - B - C - Branch
dev
: A - B - D
Scenario 1:
user@PC0T9SND MINGW64 /c/Projects/AS_Project/GitDemo (master)
$ git rebase dev master
First, rewinding head to replay your work on top of it...
Applying: Add file03
user@PC0T9SND MINGW64 /c/Projects/AS_Project/GitDemo (master)
$ git log --oneline
2ce7588 (HEAD -> master) Add file03
6b1bae9 (dev) Add file04
445cb1c Add file02
c3cab12 Add file01
Now I have a repo:
- Branch
master
: A - B - D' - C - Branch
dev
: A - B - D
To 'undo rebase', use 'git reflog && git reset --hard id'.
Scenario 2:
user@PC0T9SND MINGW64 /c/Projects/AS_Project/GitDemo (dev)
$ git rebase master dev
First, rewinding head to replay your work on top of it...
Applying: Add file04
user@PC0T9SND MINGW64 /c/Projects/AS_Project/GitDemo (dev)
$ git log --oneline
29d899d (HEAD -> dev) Add file04
0e2d274 (master) Add file03
445cb1c Add file02
c3cab12 Add file01
Now I have a repo:
- Branch
master
: A - B - C - Branch
dev
: A - B - C' - D