{"id":2277,"date":"2021-12-13T17:03:17","date_gmt":"2021-12-13T22:03:17","guid":{"rendered":"https:\/\/openlab.bmcc.cuny.edu\/mmp-350-fall-21\/?p=2277"},"modified":"2021-12-13T17:03:29","modified_gmt":"2021-12-13T22:03:29","slug":"git-cherry-pick","status":"publish","type":"post","link":"https:\/\/openlab.bmcc.cuny.edu\/mmp-350-fall-21\/tools\/git-cherry-pick\/","title":{"rendered":"Git Cherry Pick"},"content":{"rendered":"\n<p>Cherry picking in git is a relatively advance way to bring in the code from a single commit into your current working branch. <\/p>\n\n\n\n<p>Why might you want to do this? Well, a good example in our class is that I forgot to add some code to the .eleventy.js file in the <a href=\"https:\/\/github.com\/profstein\/eleventy-basic\" target=\"_blank\" rel=\"noreferrer noopener\">eleventy-basic<\/a> repository template I made on GitHub. Many of you created your projects from this. If I update that now, which I did, you won&#8217;t get the changes unless you do something like use cherry pick.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Example: Update eleventy-basic with git cherry-pick<\/h2>\n\n\n\n<p>Steps to update your file<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Open Visual Studio Code to your project that is based on eleventy-basic.<\/li><li>Open the terminal<\/li><li>Add my repository as a remote by putting the following in the Terminal:<ol><li><code><strong>git remote add stein-repo https:\/\/github.com\/profstein\/eleventy-basic.git<\/strong><\/code><\/li><\/ol><\/li><li>Run git fetch to bring down the info on my repo. type in terminal:<ol><li><code><strong>git fetch stein-repo<\/strong><\/code><\/li><\/ol><\/li><li>Make sure you&#8217;re on the right branch. Create a new one if you need to. This way if you mess it up it won&#8217;t effect anything else. You can copy below into the terminal to make a new branch.<ol><li><code><strong>git checkout -b pick-stein<\/strong><\/code><\/li><\/ol><\/li><li>Run the cherry-pick. Again paste in template<ol><li><code><strong>git cherry-pick <code>df9e35e<\/code><\/strong><\/code><\/li><\/ol><\/li><\/ol>\n\n\n\n<p>You should see a new commit in your history with my comment: &#8220;set nunjucks as template lang, install ja-yaml eleventyNavigation&#8221;<\/p>\n\n\n\n<p>It changes .eleventy.js, package.json and package-lock.json.<\/p>\n\n\n\n<p>If everythign worked out then merge this back into main<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li><code><strong>git checkout main<\/strong><\/code><\/li><li><code><strong>git merge pick-stein<\/strong><\/code><\/li><\/ol>\n\n\n\n<p>You will also need to run npm install as I added some modules you might need as part of this commit.<\/p>\n\n\n\n<p><code>npm install<\/code><\/p>\n\n\n\n<p>Here is the process again with just the git commands<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>git remote add stein-repo https:\/\/github.com\/profstein\/eleventy-basic.git<\/li><li>git fetch stein-repo<\/li><li>git checkout -b pick-stein<\/li><li>git cherry-pick df9e35e<\/li><li>git checkout main<\/li><li>git merge pick-stein<\/li><li>npm install<\/li><\/ol>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Video Tutorial<\/h2>\n\n\n\n<p>Here is a video tutorial I made that talks through the process more generally.<\/p>\n\n\n\n<figure class=\"wp-block-video\"><video controls src=\"https:\/\/www.dropbox.com\/s\/6hrczfvpdihxdi2\/git-cherry-pick.mov?dl=raw\"><\/video><\/figure>\n\n\n\n<p>Here is the Miro file I use in the tutorial: <a href=\"https:\/\/miro.com\/app\/board\/uXjVObNvJA4=\/?invite_link_id=473752031096\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/miro.com\/app\/board\/uXjVObNvJA4=\/?invite_link_id=473752031096<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Cherry picking in git is a relatively advance way to bring in the code from a single commit into your current working branch. Why might you want to do this? Well, a good example in our class is that I forgot to add some code to the .eleventy.js file in the eleventy-basic repository template I&hellip; <a class=\"more-link\" href=\"https:\/\/openlab.bmcc.cuny.edu\/mmp-350-fall-21\/tools\/git-cherry-pick\/\">Continue reading <span class=\"screen-reader-text\">Git Cherry Pick<\/span><\/a><\/p>\n","protected":false},"author":16,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","portfolio_post_id":0,"portfolio_citation":"","portfolio_annotation":"","openlab_post_visibility":"","footnotes":""},"categories":[136],"tags":[183,12,143],"coauthors":[87],"class_list":["post-2277","post","type-post","status-publish","format-standard","hentry","category-tools","tag-cherry-pick","tag-git","tag-github","entry"],"featured_image_urls_v2":{"full":"","thumbnail":"","medium":"","medium_large":"","large":"","1536x1536":"","2048x2048":"","post-thumbnail":"","gform-image-choice-sm":"","gform-image-choice-md":"","gform-image-choice-lg":""},"post_excerpt_stackable_v2":"<p>Cherry picking in git is a relatively advance way to bring in the code from a single commit into your current working branch. Why might you want to do this? Well, a good example in our class is that I forgot to add some code to the .eleventy.js file in the eleventy-basic repository template I made on GitHub. Many of you created your projects from this. If I update that now, which I did, you won&#8217;t get the changes unless you do something like use cherry pick. Example: Update eleventy-basic with git cherry-pick Steps to update your file Open Visual&hellip;<\/p>\n","category_list_v2":"<a href=\"https:\/\/openlab.bmcc.cuny.edu\/mmp-350-fall-21\/category\/tools\/\" rel=\"category tag\">Tools<\/a>","author_info_v2":{"name":"Christopher Stein","url":"https:\/\/openlab.bmcc.cuny.edu\/mmp-350-fall-21\/author\/cstein\/"},"comments_num_v2":"0 comments","uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"post-thumbnail":false,"gform-image-choice-sm":false,"gform-image-choice-md":false,"gform-image-choice-lg":false},"uagb_author_info":{"display_name":"Christopher Stein","author_link":"https:\/\/openlab.bmcc.cuny.edu\/mmp-350-fall-21\/author\/cstein\/"},"uagb_comment_info":0,"uagb_excerpt":"Cherry picking in git is a relatively advance way to bring in the code from a single commit into your current working branch. Why might you want to do this? Well, a good example in our class is that I forgot to add some code to the .eleventy.js file in the eleventy-basic repository template I&hellip;&hellip;","_links":{"self":[{"href":"https:\/\/openlab.bmcc.cuny.edu\/mmp-350-fall-21\/wp-json\/wp\/v2\/posts\/2277","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/openlab.bmcc.cuny.edu\/mmp-350-fall-21\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/openlab.bmcc.cuny.edu\/mmp-350-fall-21\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/openlab.bmcc.cuny.edu\/mmp-350-fall-21\/wp-json\/wp\/v2\/users\/16"}],"replies":[{"embeddable":true,"href":"https:\/\/openlab.bmcc.cuny.edu\/mmp-350-fall-21\/wp-json\/wp\/v2\/comments?post=2277"}],"version-history":[{"count":3,"href":"https:\/\/openlab.bmcc.cuny.edu\/mmp-350-fall-21\/wp-json\/wp\/v2\/posts\/2277\/revisions"}],"predecessor-version":[{"id":2280,"href":"https:\/\/openlab.bmcc.cuny.edu\/mmp-350-fall-21\/wp-json\/wp\/v2\/posts\/2277\/revisions\/2280"}],"wp:attachment":[{"href":"https:\/\/openlab.bmcc.cuny.edu\/mmp-350-fall-21\/wp-json\/wp\/v2\/media?parent=2277"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/openlab.bmcc.cuny.edu\/mmp-350-fall-21\/wp-json\/wp\/v2\/categories?post=2277"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/openlab.bmcc.cuny.edu\/mmp-350-fall-21\/wp-json\/wp\/v2\/tags?post=2277"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/openlab.bmcc.cuny.edu\/mmp-350-fall-21\/wp-json\/wp\/v2\/coauthors?post=2277"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}