Categories
command-line git How-To

Git: How to Cherry Pick Commits and Package them Under a Tag

I’ve pretty much come to rely on git to pull me out of any bad jams in the chaotic environment I work in.

One thing I’ve had to learn to do is cherry pick commits and package them under a tag in git.

Here’s how to do it if you were working with my newLISP project called Sitebeagle:

fork sitebeagle on this page

cd sitebeagle

git fetch –tags

git checkout 8f5bb33a771f7811d21b8c96cec67c28818de076

git checkout -b sample_cherry_pick

git cherry-pick 22aab7

git cherry-pick b1334775

git diff sample_cherry_pick..master

git tag leaving_out_one_commit

git push origin –tags

At this point, you should have a tagged branch that doesn’t have the commit with the change to the “2nd file.” The diff should look exactly like this:

diff –git a/test.lsp b/test.lsp
index 9cf1667..158b625 100755
— a/test.lsp
+++ b/test.lsp
@@ -1,6 +1,7 @@
#!/usr/bin/newlisp

; test tag test_a
+; cherry pick test 2

(load “sitebeagle.lsp”)
(load “twitter.lsp”);

Leave a Reply

Your email address will not be published.