{"id":6577,"date":"2018-12-09T13:37:10","date_gmt":"2018-12-09T13:37:10","guid":{"rendered":"http:\/\/putridparrot.com\/blog\/?p=6577"},"modified":"2018-12-09T13:37:10","modified_gmt":"2018-12-09T13:37:10","slug":"advanced-git-cli","status":"publish","type":"post","link":"https:\/\/putridparrot.com\/blog\/advanced-git-cli\/","title":{"rendered":"Advanced Git CLI"},"content":{"rendered":"<p>Having covered the &#8220;basic&#8221; commands in my previous post, I wanted to look at some of the more advanced stuff. I&#8217;m basically meaning things we probably won&#8217;t use as regularly as the previous post&#8217;s commands.<\/p>\n<p><strong>Rebasing<\/strong><\/p>\n<p>Rebasing isn&#8217;t necessarily advanced in it&#8217;s basic form but I&#8217;ve not had any real use for it so far apart from in more complicated scenarios.<\/p>\n<p>Rebasing allows us to apply commits from, for example one branch, onto another branch. For example, let&#8217;s say we created a branch off of the wrong branch and so want to move commits from the incorrect branch onto the other branch. <\/p>\n<p>So let&#8217;s assume we have <em>feature\/mybranch<\/em> and we need to rebase it onto <em>correct_branch<\/em>, then we use<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\ngit rebase --onto correct_branch feature\/mybranch \r\ngit force push\r\n<\/pre>\n<p><strong>Staging parts of a file<\/strong><\/p>\n<p>Git allows us to stage whole files\/folders as well as parts of a file. For example, maybe we&#8217;ve made several changes, but we currently only want to stage a subset of these changes. We can use<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\ngit add --patch filename\r\n\r\n\/\/ or short form\r\n\r\ngit add --p filename\r\n<\/pre>\n<p>We&#8217;ll now be presented with a list of the new lines and a lot of options. Selecting ? will list what each of the options means.<\/p>\n<p>We can use commands such as <em>e<\/em> to edit the patch diff file, allowing us to delete lines etc. that are to be staged.<\/p>\n<p>I&#8217;ll be adding further &#8220;advanced&#8221; situations\/commands and when I need them.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Having covered the &#8220;basic&#8221; commands in my previous post, I wanted to look at some of the more advanced stuff. I&#8217;m basically meaning things we probably won&#8217;t use as regularly as the previous post&#8217;s commands. Rebasing Rebasing isn&#8217;t necessarily advanced in it&#8217;s basic form but I&#8217;ve not had any real use for it so far [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[206],"tags":[],"class_list":["post-6577","post","type-post","status-publish","format-standard","hentry","category-git-2"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/6577","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/comments?post=6577"}],"version-history":[{"count":4,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/6577\/revisions"}],"predecessor-version":[{"id":6593,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/6577\/revisions\/6593"}],"wp:attachment":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/media?parent=6577"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/categories?post=6577"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/tags?post=6577"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}