{"id":164,"date":"2023-04-08T11:34:00","date_gmt":"2023-04-08T03:34:00","guid":{"rendered":"https:\/\/aabirtech.com\/shiblenomanblog\/?p=164"},"modified":"2024-08-10T11:34:58","modified_gmt":"2024-08-10T03:34:58","slug":"git-rebase-interactive-a-step-by-step-guide","status":"publish","type":"post","link":"https:\/\/aabirtech.com\/shiblenomanblog\/2023\/04\/08\/git-rebase-interactive-a-step-by-step-guide\/","title":{"rendered":"Git Rebase Interactive: A Step-by-Step Guide"},"content":{"rendered":"\n<p>Git Rebase Interactive is a powerful tool for rewriting commit history. Here&#8217;s how to use it:<\/p>\n\n\n\n<p><strong>Step 1: Rebase the Branch<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git rebase -i \"origin\/remote-branch\"<\/code><\/pre>\n\n\n\n<p><strong>Step 2: Edit the Commit History<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>pick<\/code>: Keep the commit as is<\/li>\n\n\n\n<li><code>squash<\/code>: Squash the commit into the previous commit<\/li>\n\n\n\n<li><code>edit<\/code>: Edit the commit message<\/li>\n\n\n\n<li><code>drop<\/code>: Remove the commit<\/li>\n<\/ul>\n\n\n\n<p><strong>Step 3: Save and Close<\/strong><\/p>\n\n\n\n<p>Save and close the interactive shell. Git will rebase the branch according to your changes.<\/p>\n\n\n\n<p><strong>Step 4: Push the Updated Branch<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git push --force-with-lease origin local-branch<\/code><\/pre>\n\n\n\n<p><strong>Example Output<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ git rebase \"origin\/remote-branch\" -Xtheirs\n$ git rebase -i \"origin\/remote-branch\"\n$ git push --force-with-lease origin local-branch<\/code><\/pre>\n\n\n\n<p><strong>Conclusion<\/strong><\/p>\n\n\n\n<p>Git Rebase Interactive makes it easy to squash commits, reorder commits, and push the updated branch to the remote repository. Just remember to use <code>git push --force-with-lease<\/code> to update the remote branch with the new commit history.<\/p>\n\n\n\n<p>Happy Coding \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Git Rebase Interactive is a powerful tool for rewriting commit history. Here&#8217;s how to use it: Step 1: Rebase the Branch Step 2: Edit the Commit History Step 3: Save and Close Save and close the interactive shell. Git will rebase the branch according to your changes. Step 4: Push the Updated Branch Example Output [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-164","post","type-post","status-publish","format-standard","hentry","category-git"],"acf":[],"_links":{"self":[{"href":"https:\/\/aabirtech.com\/shiblenomanblog\/wp-json\/wp\/v2\/posts\/164","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/aabirtech.com\/shiblenomanblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/aabirtech.com\/shiblenomanblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/aabirtech.com\/shiblenomanblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/aabirtech.com\/shiblenomanblog\/wp-json\/wp\/v2\/comments?post=164"}],"version-history":[{"count":2,"href":"https:\/\/aabirtech.com\/shiblenomanblog\/wp-json\/wp\/v2\/posts\/164\/revisions"}],"predecessor-version":[{"id":209,"href":"https:\/\/aabirtech.com\/shiblenomanblog\/wp-json\/wp\/v2\/posts\/164\/revisions\/209"}],"wp:attachment":[{"href":"https:\/\/aabirtech.com\/shiblenomanblog\/wp-json\/wp\/v2\/media?parent=164"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/aabirtech.com\/shiblenomanblog\/wp-json\/wp\/v2\/categories?post=164"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/aabirtech.com\/shiblenomanblog\/wp-json\/wp\/v2\/tags?post=164"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}