From 9096de500f3037780d9a945e046059ae9e45afd5 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Tue, 11 Apr 2017 17:38:56 -0500 Subject: [PATCH] Add Cherry Pick A Range Of Commits as a git til --- README.md | 3 ++- git/cherry-pick-a-range-of-commits.md | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 git/cherry-pick-a-range-of-commits.md diff --git a/README.md b/README.md index 80a58a8..337a3c2 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ smart people at [Hashrocket](http://hashrocket.com/). For a steady stream of TILs from a variety of rocketeers, checkout [til.hashrocket.com](https://til.hashrocket.com/). -_523 TILs and counting..._ +_524 TILs and counting..._ --- @@ -140,6 +140,7 @@ _523 TILs and counting..._ - [Checking Commit Ancestry](git/checking-commit-ancestry.md) - [Checkout Old Version Of A File](git/checkout-old-version-of-a-file.md) - [Checkout Previous Branch](git/checkout-previous-branch.md) +- [Cherry Pick A Range Of Commits](git/cherry-pick-a-range-of-commits.md) - [Clean Out All Local Branches](git/clean-out-all-local-branches.md) - [Clean Up Old Remote Tracking References](git/clean-up-old-remote-tracking-references.md) - [Delete All Untracked Files](git/delete-all-untracked-files.md) diff --git a/git/cherry-pick-a-range-of-commits.md b/git/cherry-pick-a-range-of-commits.md new file mode 100644 index 0000000..68a67e9 --- /dev/null +++ b/git/cherry-pick-a-range-of-commits.md @@ -0,0 +1,21 @@ +# Cherry Pick A Range Of Commits + +Git's `cherry-pick` command allows you to specify a range of commits to be +cherry picked onto the current branch. This can be done with the `A..B` +style syntax -- where `A` is the older end of the range. + +Consider a scenario with the following chain of commits: `A - B - C - D`. + +```bash +$ git cherry-pick B..D +``` + +This will cherry pick commits `C` and `D` onto `HEAD`. This is because the +lower-bound is exclusive. If you'd like to include `B` as well. Try the +following: + +```bash +$ git cherry-pick B^..D +``` + +See `man git-cherry-pick` for more details.