Git
Cherry-Pick a Range of Commits
-
Pass the range with the oldest commit first
-
The first commit is not inclusive, so use
~1
or^
to include it. -
For this range, use
git cherry-pick f0011b64ea~1..5d6d6efd0c
./2020-04-03.11.57.18.png
Git: Commit Referencing Syntax
There are a couple of different ways to refer to a commit:
- Full SHA:
7fa145658ded8b44c3df134c3161c21df9b0ad4b
- Abbreviated SHA:
7fa145
- Branch name:
branch-name
- Reflog
- Previous
HEAD
:HEAD@{1}
- Five
HEAD
s ago:HEAD@{5}
HEAD
yesterday:HEAD@{yesterday}
- Previous
- Parent:
7fa145^
- Parent of parent:
7fa145^^
or7fa145~2
- 5 parents “above” current commit:
7fa145^^^^^
or7fa145~5
Similarly for a range of commits:
- Commits reachable from
branch-a
but not frombranch-b
:branch-b..branch-a
or^branch-b branch-a
- Commits reachable from
branch-a
andbranch-b
, but not frombranch-c
:branch-a branch-b ^branch-c
- Commits reachable from
branch-a
orbranch-b
(but not both):branch-b...branch-a
(use--left-right
to disambiguate)