{"id":1677,"date":"2021-12-21T05:46:30","date_gmt":"2021-12-21T11:46:30","guid":{"rendered":"https:\/\/www.becomebetterprogrammer.com\/?p=1677"},"modified":"2022-04-25T09:37:46","modified_gmt":"2022-04-25T14:37:46","slug":"git-rebase","status":"publish","type":"post","link":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/git-rebase\/","title":{"rendered":"How to Rebase in Git: Explained Step-by-Step"},"content":{"rendered":"\n<p>Rebase is a powerful Git utility that facilitates software engineers, developers, and programmers to simplify the merge process. Whether it is your first time using the <code>rebase<\/code> Git command, or have issues completing a rebase, it can be challenging at the beginning if you are not used to rebasing.<\/p>\n\n\n\n<p>In this article we are going to explain what rebase does in Git. Then, we will show you the steps to follow when starting a rebase in Git. Finally, we will explain the reasons why you should consider using the <code>rebase<\/code> command more often.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\"><p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<\/div><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/git-rebase\/#How_Git_rebase_Works\" >How Git rebase Works<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/git-rebase\/#Steps_to_rebase_in_Git\" >Steps to rebase in Git<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/git-rebase\/#1_Checkout_feature_branch\" >1. Checkout feature branch<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/git-rebase\/#2_Pull_feature_branch_latest_commits\" >2. Pull feature branch latest commits<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/git-rebase\/#3_Remove_any_unstaged_commits_from_feature_branch_optional\" >3. Remove any unstaged commits from feature branch (optional)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/git-rebase\/#4_Checkout_branch_you_are_planning_to_rebasing_onto\" >4. Checkout branch you are planning to rebasing onto<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/git-rebase\/#5_Pull_latest_commits_of_branch_you_are_planning_to_rebase_onto\" >5. Pull latest commits of branch you are planning to rebase onto<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/git-rebase\/#6_Checkout_feature_branch\" >6. Checkout feature branch<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/git-rebase\/#7_Start_rebase\" >7. Start rebase<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/git-rebase\/#8_Fix_conflicts_during_rebase_or_skip_to_continue_rebase_or_abort_the_rebase_optional\" >8. Fix conflicts during rebase or skip to continue rebase, or abort the rebase (optional)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/git-rebase\/#10_Once_you_finish_rebasing_DO_NOT_pull_but_push_immediately_to_remote\" >10. Once you finish rebasing, DO NOT pull, but push immediately to remote<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/git-rebase\/#Reasons_why_you_should_rebase_more_often\" >Reasons why you should rebase more often<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/git-rebase\/#The_Dangers_of_Rebasing\" >The Dangers of Rebasing<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/git-rebase\/#Conclusion\" >Conclusion<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/git-rebase\/#Interested_in_Learning_more_about_Git\" >Interested in Learning more about Git?<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_Git_rebase_Works\"><\/span>How Git <code>rebase<\/code> Works<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><strong>Git <code>rebase<\/code> is the process of updating a series of commits of an existing branch to a new base commit<\/strong>. Unfortunately, explaining Git concepts doesn&#8217;t make too much sense or is hard to understand without a proper visualization of a git tree diagram. Hopefully, the following diagram will help you understand what git <code>rebase<\/code> does.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"500\" src=\"https:\/\/www.becomebetterprogrammer.com\/wp-content\/uploads\/2021\/12\/git-rebase.png\" alt=\"\" class=\"wp-image-1679\" title=\"Explanation of what git rebase does\" srcset=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-content\/uploads\/2021\/12\/git-rebase.png 800w, https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-content\/uploads\/2021\/12\/git-rebase-300x188.png 300w, https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-content\/uploads\/2021\/12\/git-rebase-768x480.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><figcaption>Explanation of what git rebase does<\/figcaption><\/figure><\/div>\n\n\n\n<p>During software development, it is typical to have a master or a main branch and multiple feature branches. Whenever we create a feature branch, the feature branch is created off of a specific branch, typically the latest commit of the master branch. <\/p>\n\n\n\n<p>As there are more people working on a project, other feature branches are created. Let&#8217;s say, you created feature branch A, and someone else created feature branch B. In this scenario, we are going to assume someone in the team has finished their development in feature B branch. Hence, it is normal for that person to merge the feature B branch to the master branch to update the main codebase typically used for production deployments.<\/p>\n\n\n\n<p>Meanwhile, you have been working in feature A branch. However, since there are new changes in master branch after merging feature B branch, feature A branch no longer has the latest changes from master branch. Hence, in case you decide to merge feature A branch to master, there is a possibility of running into conflicts.<\/p>\n\n\n\n<p>If you use the <code>rebase<\/code> command onto master branch, you will update feature A branch base commit. In other words, you would get all of the latest changes from master branch in feature A branch as if those commits happened first prior to you making commits to feature A branch, making sure feature A branch is up to date with master branch. <\/p>\n\n\n\n<p>The <code>rebase<\/code> commands have different configurations that can be used prior to starting rebasing. However, to start a rebase the only thing you should know is the name of the branch you are rebasing onto.<\/p>\n\n\n\n<pre class=\"wp-block-code language-git\"><code>git rebase &lt;branch rebasing onto&gt;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Steps_to_rebase_in_Git\"><\/span>Steps to <code>rebase<\/code> in Git<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Now that you understand what the <code>rebase<\/code> does in Git, we will show you the steps to follow when starting a rebase. For the sake of making it simpler to follow, we are going to have as a reference the following diagram.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"500\" src=\"https:\/\/www.becomebetterprogrammer.com\/wp-content\/uploads\/2021\/12\/Current-branch-checked-out-is-master-branch.png\" alt=\"\" class=\"wp-image-1683\" title=\"Example of a repository with a login-page branch\" srcset=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-content\/uploads\/2021\/12\/Current-branch-checked-out-is-master-branch.png 800w, https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-content\/uploads\/2021\/12\/Current-branch-checked-out-is-master-branch-300x188.png 300w, https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-content\/uploads\/2021\/12\/Current-branch-checked-out-is-master-branch-768x480.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><figcaption>Example of a repository with a login-page branch<\/figcaption><\/figure>\n\n\n\n<p>*Notice in the git tree structure we have a login-page branch and a master branch.<\/p>\n\n\n\n<p>These are the steps to rebase a branch in Git.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"1_Checkout_feature_branch\"><\/span>1. Checkout feature branch<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Make sure to be in the feature branch that you want to rebase.<\/p>\n\n\n\n<pre class=\"wp-block-code language-git\"><code>git checkout login-page<\/code><\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"500\" src=\"https:\/\/www.becomebetterprogrammer.com\/wp-content\/uploads\/2021\/12\/login-page-branch.png\" alt=\"\" class=\"wp-image-1682\" title=\"Check out login-page branch\" srcset=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-content\/uploads\/2021\/12\/login-page-branch.png 800w, https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-content\/uploads\/2021\/12\/login-page-branch-300x188.png 300w, https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-content\/uploads\/2021\/12\/login-page-branch-768x480.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><figcaption>Check out the login-page branch<\/figcaption><\/figure><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"2_Pull_feature_branch_latest_commits\"><\/span>2. Pull feature branch latest commits<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>We are going to pull the latest commits of the feature branch from the remote repository, even if you think you already have the latest commits in the local repository.<\/p>\n\n\n\n<pre class=\"wp-block-code language-git\"><code>git pull<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"3_Remove_any_unstaged_commits_from_feature_branch_optional\"><\/span>3. Remove any unstaged commits from feature branch (optional)<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>There might be changes in the local repository that have not been committed yet. If that is your case you have a couple of options. Either reset the branch and delete those changes or stash them. <\/p>\n\n\n\n<p>I typically stash the changes in case I need to those changes after rebasing the branch unless I have added some logs to facilitate debugging.<\/p>\n\n\n\n<pre class=\"wp-block-code language-git\"><code>git stash<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"4_Checkout_branch_you_are_planning_to_rebasing_onto\"><\/span>4. Checkout branch you are planning to rebasing onto<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Switch the current branch to the branch you are planning to rebase onto. It is common to rebase onto master branch. However, you can rebase to any other branch as well. For this tutorial, we will checkout master branch.<\/p>\n\n\n\n<pre class=\"wp-block-code language-git\"><code>git checkout master<\/code><\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.becomebetterprogrammer.com\/wp-content\/uploads\/2021\/12\/Current-branch-checked-out-is-master-branch.png\" alt=\"\" class=\"wp-image-1683\" width=\"800\" height=\"500\" title=\"Check out the master branch\" srcset=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-content\/uploads\/2021\/12\/Current-branch-checked-out-is-master-branch.png 800w, https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-content\/uploads\/2021\/12\/Current-branch-checked-out-is-master-branch-300x188.png 300w, https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-content\/uploads\/2021\/12\/Current-branch-checked-out-is-master-branch-768x480.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><figcaption>Check out the master branch<\/figcaption><\/figure><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"5_Pull_latest_commits_of_branch_you_are_planning_to_rebase_onto\"><\/span>5. Pull latest commits of branch you are planning to rebase onto<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Pull the latest commits of the branch you are planning to rebase onto from the remote repository. <strong>This step is very important<\/strong> as it will use the last commit from that branch to set a new base commit of the feature branch.<\/p>\n\n\n\n<pre class=\"wp-block-code language-git\"><code>git pull<\/code><\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"500\" src=\"https:\/\/www.becomebetterprogrammer.com\/wp-content\/uploads\/2021\/12\/pulling-latest-commits-from-master-branch.png\" alt=\"\" class=\"wp-image-1684\" title=\"Pulling latest changes from master branch\" srcset=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-content\/uploads\/2021\/12\/pulling-latest-commits-from-master-branch.png 800w, https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-content\/uploads\/2021\/12\/pulling-latest-commits-from-master-branch-300x188.png 300w, https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-content\/uploads\/2021\/12\/pulling-latest-commits-from-master-branch-768x480.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><figcaption>Pulling latest changes from the master branch<\/figcaption><\/figure><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"6_Checkout_feature_branch\"><\/span>6. Checkout feature branch<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>After getting the latest commits of the branch you are rebasing onto, you are going to switch back to the feature branch<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"500\" src=\"https:\/\/www.becomebetterprogrammer.com\/wp-content\/uploads\/2021\/12\/Checkout-feature-branch-after-pulling-latest-from-master-branch.png\" alt=\"\" class=\"wp-image-1685\" title=\"Checkout the login-page branch after pulling latest from master branch\" srcset=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-content\/uploads\/2021\/12\/Checkout-feature-branch-after-pulling-latest-from-master-branch.png 800w, https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-content\/uploads\/2021\/12\/Checkout-feature-branch-after-pulling-latest-from-master-branch-300x188.png 300w, https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-content\/uploads\/2021\/12\/Checkout-feature-branch-after-pulling-latest-from-master-branch-768x480.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><figcaption>Checkout the login-page branch after pulling the latest from the master branch<\/figcaption><\/figure><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"7_Start_rebase\"><\/span>7. Start rebase<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Start to rebase in the feature branch by using the name of the branch you are rebasing onto.<\/p>\n\n\n\n<pre class=\"wp-block-code language-git\"><code>git rebase master<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"8_Fix_conflicts_during_rebase_or_skip_to_continue_rebase_or_abort_the_rebase_optional\"><\/span>8. Fix conflicts during rebase or skip to continue rebase, or abort the rebase (optional)<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>There can be conflicts that need to be resolved during a rebase. If you run into conflicts, the terminal will display a message starting with the word <code>CONFLICT Merge conflict in<\/code> followed by the path of the file with conflicts.<\/p>\n\n\n\n<p>Open the file and resolve conflicts. Once conflicts are resolved, make sure to stage the file.<\/p>\n\n\n\n<pre class=\"wp-block-code language-git\"><code>git add .\/path\/of\/file\/with\/conflicts<\/code><\/pre>\n\n\n\n<p>Verify the conflicted files are staged using the <code>status<\/code> command.<\/p>\n\n\n\n<pre class=\"wp-block-code language-git\"><code>git status<\/code><\/pre>\n\n\n\n<p>After that, <strong>make sure to to not commit those changes.<\/strong> Instead, you want to continue the rebase as the rebase hasn&#8217;t finished yet.<\/p>\n\n\n\n<pre class=\"wp-block-code language-git\"><code>git rebase --continue<\/code><\/pre>\n\n\n\n<p>In the case you don&#8217;t want to bypass the commit that caused the conflict, you can skip it.<\/p>\n\n\n\n<pre class=\"wp-block-code language-git\"><code>git rebase --skip<\/code><\/pre>\n\n\n\n<p>Finally, you can always opt to <\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"10_Once_you_finish_rebasing_DO_NOT_pull_but_push_immediately_to_remote\"><\/span>10. Once you finish rebasing, DO NOT pull, but push immediately to remote<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>You will see the rebase is completed because the terminal will throw the following message:<\/p>\n\n\n\n<p><code>Successfully rebased and updated<\/code><\/p>\n\n\n\n<p>At that point, the feature branch in your local repository is rebased. Hence, the base commit of the feature branch is updated. However, the feature branch in the remote repository still doesn&#8217;t have the base commit updated. <\/p>\n\n\n\n<p>If you decide to pull the latest commits from the remote repository, it will cause conflicts, as the base commits from both repositories, are not the same. Therefore, we need to force to push local repository commits to remote.<\/p>\n\n\n\n<p><strong>It is highly recommended to use <code>--force-with-lease<\/code> than to use <code>--force<\/code> when pushing to remote after a rebase<\/strong> as <code>--force<\/code> overwrites the remote branch with a local branch. While in theory <code>--force-with-lease<\/code> has a similar outcome, it is a safer option as it won&#8217;t overwrite any commits on the remote branch that someone else might have added while you were rebasing. This will save headaches in case you overwrite someone else&#8217;s code and have to find out what was overwritten. <\/p>\n\n\n\n<pre class=\"wp-block-code language-git\"><code>git push --force-with-lease<\/code><\/pre>\n\n\n\n<p>*In case the push <code>--force-with-lease<\/code> fails, my recommendation is to do a hard reset of the feature branch in the local repository to match the remote repository. Then, start the rebase all over again. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Reasons_why_you_should_rebase_more_often\"><\/span>Reasons why you should <code>rebase<\/code> more often<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Adopting the usage of the <code>rebase<\/code> command can have positive effects when done correctly. Here is a list of some of the benefits when you and your team rebase more often <\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>It allows to maintain a linear project history<\/li><li>Rebase allows for safer\/simpler merges<\/li><li>Prevent the possibilities programmatic test from failing after merging<\/li><li>It reduces merge conflicts<\/li><li>Rebase helps to keep up to date commits from on another branch as you work in your local feature branch<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"The_Dangers_of_Rebasing\"><\/span>The Dangers of Rebasing<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Just like any other tool, there can be dangers of using it when not done correctly, and rebasing is not the exception. Here are some problems you can face when using rebase.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Rebase can rewrite the commit history as you can&#8217;t update remote using only <code>push<\/code>, but instead you have to force push<\/li><li>There could be a lot of merge conflicts during a rebase if a branch is not rebased often<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>All in all, rebase is a powerful tool not many developers are aware of or not sure how to use it as it helps to keep commits up to date in relation to another branch, reducing and even removing the existence of merge conflicts. However, using the <code>rebase<\/code> command can have negative effects if the developer is not sure of how to use it as contrary to merging, rebase doesn&#8217;t preserve the commit history.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Interested_in_Learning_more_about_Git\"><\/span>Interested in Learning more about Git?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>I wrote other articles explaining how to use other git commands, and I thought you might be interested in reading some of them since you are reading this.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/www.becomebetterprogrammer.com\/git-alias\/\">The Complete Guide to Git Alias: Shorcuts to Be Efficient<\/a><\/li><li><a href=\"https:\/\/www.becomebetterprogrammer.com\/git-revert-last-commit\/\">How to Revert to Last Commit Locally and Remote in Git<\/a><\/li><li><a href=\"https:\/\/www.becomebetterprogrammer.com\/git-head\">What is Git HEAD? A Practical Guide Explained with Examples<\/a><\/li><li><a href=\"https:\/\/www.becomebetterprogrammer.com\/learn-how-to-use-version-control-with-git-and-github-the-absolute-guide-for-beginners\/\">Learn How to Use Version Control with Git and GitHub: The Absolute Guide for Beginners<\/a><\/li><li><a href=\"https:\/\/www.becomebetterprogrammer.com\/how-to-update-github-personal-access-tokens\/\">How to Update GitHub Personal Access Tokens?<\/a><\/li><\/ul>\n\n\n\n<p class=\"has-text-align-left\"><strong>Did you like this article?<\/strong><\/p>\n\n\n\n<p class=\"has-text-align-left\">Share your thoughts by replying on <a href=\"https:\/\/twitter.com\/bbprogrammer\" target=\"_blank\" rel=\"noreferrer noopener\">Twitter of Become A Better Programmer<\/a> or to <a href=\"https:\/\/twitter.com\/arealesramirez\" target=\"_blank\" rel=\"noreferrer noopener\">personal my Twitter account<\/a>.<\/p>\n\n\n\n<figure class=\"wp-block-embed aligncenter is-type-rich is-provider-twitter wp-block-embed-twitter\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"twitter-tweet\" data-width=\"550\" data-dnt=\"true\"><p lang=\"en\" dir=\"ltr\">Have you ever used git rebase before? Do you know what it does?<br><br>git rebase helps you keep your branch up to date in relation to other branches without the need of merging.<br><br>Interested in learning more?<a href=\"https:\/\/t.co\/jL56nYfBJo\">https:\/\/t.co\/jL56nYfBJo<\/a><\/p>&mdash; Become A Better Programmer (@bbprogrammer) <a href=\"https:\/\/twitter.com\/bbprogrammer\/status\/1473634768113786883?ref_src=twsrc%5Etfw\" target=\"_blank\" rel=\"noopener\">December 22, 2021<\/a><\/blockquote><script async src=\"https:\/\/platform.twitter.com\/widgets.js\" charset=\"utf-8\"><\/script>\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Rebase is a powerful tool that helps to keep commits up to date in relation to another branch. This article explains how to use rebase step-by-step<\/p>\n","protected":false},"author":1,"featured_media":1690,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[28,14],"tags":[],"class_list":["post-1677","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-git","category-tutorial","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50"],"_links":{"self":[{"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/posts\/1677","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/comments?post=1677"}],"version-history":[{"count":5,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/posts\/1677\/revisions"}],"predecessor-version":[{"id":2471,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/posts\/1677\/revisions\/2471"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/media\/1690"}],"wp:attachment":[{"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/media?parent=1677"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/categories?post=1677"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/tags?post=1677"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}