Git merge rebase cherry-pick 以及 游离commit 的测试

时间:2023-03-09 08:07:49
Git merge rebase cherry-pick 以及 游离commit 的测试
 Microsoft Windows [版本 10.0.17134.345]
(c) Microsoft Corporation。保留所有权利。 C:\Users\zhangyang\Desktop\branch>git init
Initialized empty Git repository in C:/Users/zhangyang/Desktop/branch/.git/ C:\Users\zhangyang\Desktop\branch>git commit -m "Init Commit" --allow-empty
[master (root-commit) 468be32] Init Commit C:\Users\zhangyang\Desktop\branch>git commit -m "C1" --allow-empty
[master f91e414] C1 C:\Users\zhangyang\Desktop\branch>git commit -m "C2" --allow-empty
[master c738d28] C2 C:\Users\zhangyang\Desktop\branch>git commit -m "C3" --allow-empty
[master 09c5904] C3 C:\Users\zhangyang\Desktop\branch>git checkout -b branch1
Switched to a new branch 'branch1' C:\Users\zhangyang\Desktop\branch>git commit -m "C4" --allow-empty
[branch1 60f5e77] C4 C:\Users\zhangyang\Desktop\branch>git commit -m "C5" --allow-empty
[branch1 85a8fe7] C5 C:\Users\zhangyang\Desktop\branch>git log --oneline --decorate --graph --all
* 85a8fe7 (HEAD -> branch1) C5
* 60f5e77 C4
* 09c5904 (master) C3
* c738d28 C2
* f91e414 C1
* 468be32 Init Commit C:\Users\zhangyang\Desktop\branch>git checkout 85a9fe7
error: pathspec '85a9fe7' did not match any file(s) known to git. C:\Users\zhangyang\Desktop\branch>git checkout 85a8fe7
Note: checking out '85a8fe7'. You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout. If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example: git checkout -b <new-branch-name> HEAD is now at 85a8fe7 C5 C:\Users\zhangyang\Desktop\branch>git commit -m "C6" --allow-empty
[detached HEAD 3f0d0e2] C6 C:\Users\zhangyang\Desktop\branch>git commit -m "C7" --allow-empty
[detached HEAD 9724be1] C7 C:\Users\zhangyang\Desktop\branch>git commit -m "C8" --allow-empty
[detached HEAD ba2e2d2] C8 C:\Users\zhangyang\Desktop\branch>git status
HEAD detached from 85a8fe7
nothing to commit, working tree clean C:\Users\zhangyang\Desktop\branch>git log --oneline --decorate --graph --all
* ba2e2d2 (HEAD) C8
* 9724be1 C7
* 3f0d0e2 C6
* 85a8fe7 (branch1) C5
* 60f5e77 C4
* 09c5904 (master) C3
* c738d28 C2
* f91e414 C1
* 468be32 Init Commit C:\Users\zhangyang\Desktop\branch>git show 3f0d0e2
commit 3f0d0e290a94035f504cb1fb43065b09ed782172
Author: yqmcu <yqmcu@foxmail.com>
Date: Mon Feb :: + C6 C:\Users\zhangyang\Desktop\branch>git show 85a8fe7
commit 85a8fe7ad54cde82285d866536a8d7cd6d74f6cb (branch1)
Author: yqmcu <yqmcu@foxmail.com>
Date: Mon Feb :: + C5 C:\Users\zhangyang\Desktop\branch>git checkout -b HEAD
fatal: 'HEAD' is not a valid branch name. C:\Users\zhangyang\Desktop\branch>git checkout -b detached
Switched to a new branch 'detached' C:\Users\zhangyang\Desktop\branch>git log --oneline --decorate --all --graph
* ba2e2d2 (HEAD -> detached) C8
* 9724be1 C7
* 3f0d0e2 C6
* 85a8fe7 (branch1) C5
* 60f5e77 C4
* 09c5904 (master) C3
* c738d28 C2
* f91e414 C1
* 468be32 Init Commit C:\Users\zhangyang\Desktop\branch>git checkout branch1
Switched to branch 'branch1' C:\Users\zhangyang\Desktop\branch>git cherry-pick detached
The previous cherry-pick is now empty, possibly due to conflict resolution.
If you wish to commit it anyway, use: git commit --allow-empty Otherwise, please use 'git reset'
On branch branch1
You are currently cherry-picking commit ba2e2d2. nothing to commit, working tree clean C:\Users\zhangyang\Desktop\branch>git log --oneline --decorate --all --graph
* ba2e2d2 (detached) C8
* 9724be1 C7
* 3f0d0e2 C6
* 85a8fe7 (HEAD -> branch1) C5
* 60f5e77 C4
* 09c5904 (master) C3
* c738d28 C2
* f91e414 C1
* 468be32 Init Commit C:\Users\zhangyang\Desktop\branch>git commit --allow-empty
[branch1 7edcbff] C8
Date: Mon Feb :: + C:\Users\zhangyang\Desktop\branch>git log --oneline --decorate --all --graph
* 7edcbff (HEAD -> branch1) C8
| * ba2e2d2 (detached) C8
| * 9724be1 C7
| * 3f0d0e2 C6
|/
* 85a8fe7 C5
* 60f5e77 C4
* 09c5904 (master) C3
* c738d28 C2
* f91e414 C1
* 468be32 Init Commit C:\Users\zhangyang\Desktop\branch>git log --oneline --decorate --graph
* 7edcbff (HEAD -> branch1) C8
* 85a8fe7 C5
* 60f5e77 C4
* 09c5904 (master) C3
* c738d28 C2
* f91e414 C1
* 468be32 Init Commit C:\Users\zhangyang\Desktop\branch>git checkout master
Switched to branch 'master' C:\Users\zhangyang\Desktop\branch>git rebase merge branch1 --no-ff
fatal: Needed a single revision
invalid upstream 'merge' C:\Users\zhangyang\Desktop\branch>git merge branch1 --no-ff
Already up to date!
Merge made by the 'recursive' strategy. C:\Users\zhangyang\Desktop\branch>git log --oneline --decorate --graph
* 6e2328f (HEAD -> master) Merge branch 'branch1'
|\
| * 7edcbff (branch1) C8
| * 85a8fe7 C5
| * 60f5e77 C4
|/
* 09c5904 C3
* c738d28 C2
* f91e414 C1
* 468be32 Init Commit C:\Users\zhangyang\Desktop\branch>git log --oneline --decorate --graph --all
* 6e2328f (HEAD -> master) Merge branch 'branch1'
|\
| * 7edcbff (branch1) C8
| | * ba2e2d2 (detached) C8
| | * 9724be1 C7
| | * 3f0d0e2 C6
| |/
| * 85a8fe7 C5
| * 60f5e77 C4
|/
* 09c5904 C3
* c738d28 C2
* f91e414 C1
* 468be32 Init Commit C:\Users\zhangyang\Desktop\branch>git checkout -b --help
fatal: '--help' is not a valid branch name. C:\Users\zhangyang\Desktop\branch>git checkout --help C:\Users\zhangyang\Desktop\branch>git checkout -b old 85a8fe7
Switched to a new branch 'old' C:\Users\zhangyang\Desktop\branch>git log --oneline --graph
* 85a8fe7 (HEAD -> old) C5
* 60f5e77 C4
* 09c5904 C3
* c738d28 C2
* f91e414 C1
* 468be32 Init Commit C:\Users\zhangyang\Desktop\branch>git cherry-pick branch1
The previous cherry-pick is now empty, possibly due to conflict resolution.
If you wish to commit it anyway, use: git commit --allow-empty Otherwise, please use 'git reset'
On branch old
You are currently cherry-picking commit 7edcbff. nothing to commit, working tree clean C:\Users\zhangyang\Desktop\branch>git commit --allow-empty
[old 11d5930] C8
Date: Mon Feb :: + C:\Users\zhangyang\Desktop\branch>git log --oneline --graph
* 11d5930 (HEAD -> old) C8
* 85a8fe7 C5
* 60f5e77 C4
* 09c5904 C3
* c738d28 C2
* f91e414 C1
* 468be32 Init Commit C:\Users\zhangyang\Desktop\branch>git reset 85a8fe7 --hard
HEAD is now at 85a8fe7 C5 C:\Users\zhangyang\Desktop\branch>git log --oneline --graph
* 85a8fe7 (HEAD -> old) C5
* 60f5e77 C4
* 09c5904 C3
* c738d28 C2
* f91e414 C1
* 468be32 Init Commit C:\Users\zhangyang\Desktop\branch>git rebase branch1
First, rewinding head to replay your work on top of it...
Fast-forwarded old to branch1. C:\Users\zhangyang\Desktop\branch>git log --oneline --graph
* 7edcbff (HEAD -> old, branch1) C8
* 85a8fe7 C5
* 60f5e77 C4
* 09c5904 C3
* c738d28 C2
* f91e414 C1
* 468be32 Init Commit C:\Users\zhangyang\Desktop\branch>git reset 85a8fe7 --hard
HEAD is now at 85a8fe7 C5 C:\Users\zhangyang\Desktop\branch>git log --oneline --graph
* 85a8fe7 (HEAD -> old) C5
* 60f5e77 C4
* 09c5904 C3
* c738d28 C2
* f91e414 C1
* 468be32 Init Commit C:\Users\zhangyang\Desktop\branch>git merge branch1 --no-ff
Already up to date!
Merge made by the 'recursive' strategy. C:\Users\zhangyang\Desktop\branch>git log --oneline --graph
* a6aea9e (HEAD -> old) Merge branch 'branch1' into old
|\
| * 7edcbff (branch1) C8
|/
* 85a8fe7 C5
* 60f5e77 C4
* 09c5904 C3
* c738d28 C2
* f91e414 C1
* 468be32 Init Commit C:\Users\zhangyang\Desktop\branch>git reset 85a8fe7 --hard
HEAD is now at 85a8fe7 C5 C:\Users\zhangyang\Desktop\branch>git rebase detached
First, rewinding head to replay your work on top of it...
Fast-forwarded old to detached. C:\Users\zhangyang\Desktop\branch>git log --oneline --graph
* ba2e2d2 (HEAD -> old, detached) C8
* 9724be1 C7
* 3f0d0e2 C6
* 85a8fe7 C5
* 60f5e77 C4
* 09c5904 C3
* c738d28 C2
* f91e414 C1
* 468be32 Init Commit C:\Users\zhangyang\Desktop\branch>git log --oneline --graph
* ba2e2d2 (HEAD -> old, detached) C8
* 9724be1 C7
* 3f0d0e2 C6
* 85a8fe7 C5
* 60f5e77 C4
* 09c5904 C3
* c738d28 C2
* f91e414 C1
* 468be32 Init Commit C:\Users\zhangyang\Desktop\branch>git log --oneline --graph --all --decorate
* 6e2328f (master) Merge branch 'branch1'
|\
| * 7edcbff (branch1) C8
| | * ba2e2d2 (HEAD -> old, detached) C8
| | * 9724be1 C7
| | * 3f0d0e2 C6
| |/
| * 85a8fe7 C5
| * 60f5e77 C4
|/
* 09c5904 C3
* c738d28 C2
* f91e414 C1
* 468be32 Init Commit C:\Users\zhangyang\Desktop\branch>git checkout master
Switched to branch 'master' C:\Users\zhangyang\Desktop\branch>git reset 09c5904 --hard
HEAD is now at 09c5904 C3 C:\Users\zhangyang\Desktop\branch>git log --oneline --graph --all --decorate
* 7edcbff (branch1) C8
| * ba2e2d2 (old, detached) C8
| * 9724be1 C7
| * 3f0d0e2 C6
|/
* 85a8fe7 C5
* 60f5e77 C4
* 09c5904 (HEAD -> master) C3
* c738d28 C2
* f91e414 C1
* 468be32 Init Commit C:\Users\zhangyang\Desktop\branch>git checkout branch1
Switched to branch 'branch1' C:\Users\zhangyang\Desktop\branch>git reset 85a8fe7 --hard
HEAD is now at 85a8fe7 C5 C:\Users\zhangyang\Desktop\branch>git log --oneline --graph --all --decorate
* ba2e2d2 (old, detached) C8
* 9724be1 C7
* 3f0d0e2 C6
* 85a8fe7 (HEAD -> branch1) C5
* 60f5e77 C4
* 09c5904 (master) C3
* c738d28 C2
* f91e414 C1
* 468be32 Init Commit C:\Users\zhangyang\Desktop\branch>git rebase detached
First, rewinding head to replay your work on top of it...
Fast-forwarded branch1 to detached. C:\Users\zhangyang\Desktop\branch>git log --oneline --graph --all --decorate
* ba2e2d2 (HEAD -> branch1, old, detached) C8
* 9724be1 C7
* 3f0d0e2 C6
* 85a8fe7 C5
* 60f5e77 C4
* 09c5904 (master) C3
* c738d28 C2
* f91e414 C1
* 468be32 Init Commit C:\Users\zhangyang\Desktop\branch>git checkout master
Switched to branch 'master' C:\Users\zhangyang\Desktop\branch>git log --oneline --graph --all --decorate
* ba2e2d2 (old, detached, branch1) C8
* 9724be1 C7
* 3f0d0e2 C6
* 85a8fe7 C5
* 60f5e77 C4
* 09c5904 (HEAD -> master) C3
* c738d28 C2
* f91e414 C1
* 468be32 Init Commit C:\Users\zhangyang\Desktop\branch>git merge branch1 --no-ff
Already up to date!
Merge made by the 'recursive' strategy. C:\Users\zhangyang\Desktop\branch>git log --oneline --graph --all --decorate
* 6e056d3 (HEAD -> master) Merge branch 'branch1'
|\
| * ba2e2d2 (old, detached, branch1) C8
| * 9724be1 C7
| * 3f0d0e2 C6
| * 85a8fe7 C5
| * 60f5e77 C4
|/
* 09c5904 C3
* c738d28 C2
* f91e414 C1
* 468be32 Init Commit C:\Users\zhangyang\Desktop\branch>