Git cherry-pick
2019-06-11 本文已影响0人
JaedenKil
xx@PC0T9SND MINGW64 /c/xx/GitDemo (master)
$ git log --oneline
bcb5b95 (HEAD -> master) Add file06
870b980 Add file05
5b14e0b Add file04
2806b3e (dev) Add file03
37dfeb1 Add file02
01f470d Add file01
So basically I want to pick a few commits and apply to the branch dev
.
xx@PC0T9SND MINGW64 /c/xx/GitDemo (dev)
$ git cherry-pick 5b14e0b..bcb5b95
[dev ae52ab3] Add file05
Date: Tue Jun 11 14:59:47 2019 +0800
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 file05
[dev e0ca326] Add file06
Date: Tue Jun 11 15:00:17 2019 +0800
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 file06
xx@PC0T9SND MINGW64 /c/xx/GitDemo (dev)
$ git log --oneline
e0ca326 (HEAD -> dev) Add file06
ae52ab3 Add file05
2806b3e Add file03
37dfeb1 Add file02
01f470d Add file01
-
git cherry-pick a..b
a
should be older thanb
, else an error will be thrownerror: empty commit set passed
-
git cherry-pick a..b
a
is not included, whileb
is included - If wish to include
a
, use commandgit cherry-pick a^..b
instead
xx@PC0T9SND MINGW64 /c/xx/GitDemo (dev)
$ git cherry-pick 5b14e0b^..bcb5b95
[dev 1287f3b] Add file04
Date: Tue Jun 11 14:59:33 2019 +0800
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 file04
[dev 9c3fbc6] Add file05
Date: Tue Jun 11 14:59:47 2019 +0800
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 file05
[dev 851a2c3] Add file06
Date: Tue Jun 11 15:00:17 2019 +0800
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 file06
xx@PC0T9SND MINGW64 /c/xx/GitDemo (dev)
$ git log --oneline
851a2c3 (HEAD -> dev) Add file06
9c3fbc6 Add file05
1287f3b Add file04
2806b3e Add file03
37dfeb1 Add file02
01f470d Add file01