<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Shehroz Irfan</title>
    <description>The latest articles on DEV Community by Shehroz Irfan (@shehrozirfan).</description>
    <link>https://dev.to/shehrozirfan</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F757636%2F9f1591e6-013b-415f-93bf-9e461ac54a81.jpeg</url>
      <title>DEV Community: Shehroz Irfan</title>
      <link>https://dev.to/shehrozirfan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/shehrozirfan"/>
    <language>en</language>
    <item>
      <title>Git commands to get information about changes made to your files</title>
      <dc:creator>Shehroz Irfan</dc:creator>
      <pubDate>Sat, 05 Feb 2022 17:44:54 +0000</pubDate>
      <link>https://dev.to/shehrozirfan/git-commands-to-get-information-about-changes-made-to-your-files-4ge9</link>
      <guid>https://dev.to/shehrozirfan/git-commands-to-get-information-about-changes-made-to-your-files-4ge9</guid>
      <description>&lt;p&gt;Hi,&lt;br&gt;
In this article you will learn git commands which you can use to get information about the changes made to your files. Below is the list of commands that you'll learn in this article. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;git log&lt;/li&gt;
&lt;li&gt;git log -p&lt;/li&gt;
&lt;li&gt;git show&lt;/li&gt;
&lt;li&gt;git log --stat&lt;/li&gt;
&lt;li&gt;git diff&lt;/li&gt;
&lt;li&gt;git diff --staged&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;br&gt;
 &lt;code&gt;git log&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;&lt;em&gt;git log&lt;/em&gt;&lt;/strong&gt; command shows the list of all commits that have been made in the current git repository. &lt;br&gt;
Let's see the output when using git log:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffrakl34ol2hrcwc8sfmz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffrakl34ol2hrcwc8sfmz.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the image above you can see, by default the git log shows the &lt;em&gt;commit id&lt;/em&gt;, &lt;em&gt;author&lt;/em&gt;, &lt;em&gt;date&lt;/em&gt;, and &lt;em&gt;commit message&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;br&gt;
 &lt;code&gt;git log -p&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;&lt;em&gt;git log&lt;/em&gt;&lt;/strong&gt; shows the list of all the commits. But what if you want to see the actual lines changed in each commit? &lt;br&gt;
So, in this case you can use the &lt;strong&gt;&lt;em&gt;-p&lt;/em&gt;&lt;/strong&gt; flag with &lt;strong&gt;&lt;em&gt;git log&lt;/em&gt;&lt;/strong&gt;. Here &lt;strong&gt;p&lt;/strong&gt; comes from patch, because using this flag gives us the patch that was created.&lt;br&gt;
Let's see the output when using &lt;strong&gt;&lt;em&gt;git log -p&lt;/em&gt;&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm32lqz5f98favlxni8b4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm32lqz5f98favlxni8b4.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the image above you can see that it shows the added lines with plus(+) and removed lines with minus(-), and as the amount of output text is longer than what fits on the screen, git automatically uses a paging tool that allows you to scroll using page up, page down and arrows keys. You can quit the paging tool by entering 'q' from your keyboard. In the output you have one commit below the other and each commit takes up the different space depending on how many lines were added or removed in that commit.&lt;/p&gt;

&lt;p&gt;&lt;br&gt;
 &lt;code&gt;git show&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;To see the actual lines changed in a specific commit you can use &lt;strong&gt;&lt;em&gt;git show&lt;/em&gt;&lt;/strong&gt; command. The git show command takes the &lt;em&gt;commit id&lt;/em&gt; and then shows the files changed in that commit. You can get the commit id of a specific commit by using &lt;em&gt;git log&lt;/em&gt;. Let say you have a &lt;em&gt;commit id&lt;/em&gt;: '8a0d3873714c16cb8cc3810fe4861a770892ea97', now you can see the files changed to this commit using:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git show 8a0d3873714c16cb8cc3810fe4861a770892ea97&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Below is the output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fem77i7ric7ie19fqc407.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fem77i7ric7ie19fqc407.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the image above you can see that it only showed the patch of that specific commit. The benefit of using git show is that you don't need to scroll to a specific commit in the output of &lt;strong&gt;&lt;em&gt;git log -p&lt;/em&gt;&lt;/strong&gt; to see the files changed. You can directly see the files changed by providing the &lt;em&gt;commit id&lt;/em&gt; to &lt;em&gt;git show&lt;/em&gt; command.&lt;/p&gt;

&lt;p&gt;&lt;br&gt;
 &lt;code&gt;git log --stat&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;It is the interesting command that shows the stats about commits such as how many files are changed and how many lines are added or removed.&lt;br&gt;
Lets see the output when using &lt;strong&gt;&lt;em&gt;git log --stat&lt;/em&gt;&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flkumfhg9tx730nl196mh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flkumfhg9tx730nl196mh.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the image above you can see it showed the stats such as the number of files changed and the number of insertions and deletions.&lt;/p&gt;

&lt;p&gt;&lt;br&gt;
 &lt;code&gt;git diff&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;This command shows the changes made to the files and the output is same as linux &lt;strong&gt;&lt;em&gt;diff -u&lt;/em&gt;&lt;/strong&gt; command. But one point to be noted here is that git diff only shows the &lt;strong&gt;un-staged&lt;/strong&gt;(the changes that are not added to the staging area) changes. &lt;br&gt;
Let's see the output when using git diff:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1zsdz9h76u1ag5vh8ida.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1zsdz9h76u1ag5vh8ida.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the image above you can see that git diff shows the changes made to the file by plus(+) and minus(-) representing the insertions and deletions.&lt;/p&gt;

&lt;p&gt;&lt;br&gt;
 &lt;code&gt;git diff --staged&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;As I mentioned above &lt;strong&gt;&lt;em&gt;git diff&lt;/em&gt;&lt;/strong&gt; only shows the un-staged changes. So, if you want to see the changed made to the files that are staged you can use &lt;strong&gt;&lt;em&gt;--staged&lt;/em&gt;&lt;/strong&gt; flag with git diff. It will show the changes made to the files present in the staging area.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;There are plenty of other commands that you can use to get information about changes made. You can always use the &lt;a href="https://git-scm.com/docs" rel="noopener noreferrer"&gt;reference documentation&lt;/a&gt; to find out more.&lt;br&gt;
Thanks for reading!&lt;/p&gt;

</description>
      <category>git</category>
      <category>vcs</category>
      <category>opensource</category>
      <category>github</category>
    </item>
    <item>
      <title>Remote form submission and AJAX in Rails</title>
      <dc:creator>Shehroz Irfan</dc:creator>
      <pubDate>Sun, 23 Jan 2022 13:00:36 +0000</pubDate>
      <link>https://dev.to/shehrozirfan/remote-form-submission-and-ajax-in-rails-15e6</link>
      <guid>https://dev.to/shehrozirfan/remote-form-submission-and-ajax-in-rails-15e6</guid>
      <description>&lt;p&gt;Hi,&lt;br&gt;
In this article, you'll learn what is Ajax and remote form submission in rails.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What is Ajax?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;First of all, you need to know what actually Ajax is and for what purpose it is used. Let's understand this in simple words:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What happens when we visit a website?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When we visit a website a webpage is loaded from the server and if we want to see the new or updated information then we have to reload the webpage. So, this is a &lt;strong&gt;synchronous flow&lt;/strong&gt;. The new data will be presented only when the webpage is requested from the server.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What if we don't want to reload the page or what if we only want to update some section of our current page without reloading the page?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So, this is where &lt;strong&gt;AJAX(Asynchronous Javascript and XML)&lt;/strong&gt; comes in. Ajax is a mixture of several technologies and allows the client-side changes without reloading the page.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Remote form submission in Rails&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Now let's dive deeply into Ajax by submitting a remote form using AJAX in Rails because adding Ajax to web forms is a common practice and Rails makes Ajax easy to implement.&lt;/p&gt;

&lt;p&gt;In the example below, we will first create a simple form to get the user data and when the form is submitted we will save the user data and in response render a partial displaying the user information without reloading the page.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Submitting a form using AJAX *&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Controller name:&lt;/strong&gt; &lt;em&gt;Dashboard&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;Action which displays the form:&lt;/strong&gt; &lt;em&gt;new_user&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;Action which responds to Ajax request:&lt;/strong&gt; &lt;em&gt;save_new_user&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creating the form with remote true&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When you're creating the form you just need to add &lt;/p&gt;

&lt;p&gt;&lt;code&gt;remote: true&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;in the form tag and rails automagically uses Ajax.&lt;/p&gt;

&lt;p&gt;new_user.html.erb&lt;br&gt;
&lt;code&gt;&lt;br&gt;
&amp;lt;%= form_for @user, url: save_new_user_dashboard_index_path, html: { method: :post }, remote: true do |f| %&amp;gt;&lt;br&gt;
.&lt;br&gt;
.&lt;br&gt;
.&lt;br&gt;
&amp;lt;% end %&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The actual HTML generated by the ERb is:&lt;/p&gt;

&lt;p&gt;`&lt;/p&gt;

&lt;p&gt;.&lt;br&gt;
.&lt;br&gt;
.&lt;/p&gt;

&lt;p&gt;`&lt;/p&gt;

&lt;p&gt;As you can see it sets the variable data-remote="true" inside the form tag, which tells Rails to allow the form to be&lt;br&gt;
handled by JavaScript.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Making the controller respond to Ajax requests&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As our form is ready, now we need to make our controller respond to Ajax requests and this can be done by using the respond_to method.&lt;/p&gt;

&lt;p&gt;dashboard_controller.rb&lt;br&gt;
&lt;code&gt;&lt;br&gt;
def save_new_user&lt;br&gt;
    @user = User.create(new_user_params)&lt;br&gt;
    respond_to do |format|&lt;br&gt;
      format.html {redirect_to new_user_dashboard_index_path}&lt;br&gt;
      format.js&lt;br&gt;
    end&lt;br&gt;
end&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The above syntax might be confusing, but it is important to understand only one of the lines gets executed. In&lt;br&gt;
this sense, &lt;strong&gt;respond_to&lt;/strong&gt; is more like an if-then-else&lt;br&gt;
statement than a series of sequential lines. When there is an Ajax request(i.e, when remote: true is set) then format.js will be executed otherwise format.html will be executed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creating Javascript embedded ruby file&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When format.js will be executed, rails automatically calls a Javascript embedded ruby(.js.erb) file with the same name as the action name.&lt;br&gt;
Inside a JS-ERb file, Rails automatically provides the&lt;br&gt;
jQuery JavaScript helpers needed to manipulate the page&lt;br&gt;
using the Document Object Model (DOM). JS-ERb files also allow the use of embedded Ruby which we apply in the save_new_user.js.erb file to render a partial with user information. We'll use the &lt;a href="https://api.rubyonrails.org/classes/ActionView/Helpers/JavaScriptHelper.html#method-i-escape_javascript" rel="noopener noreferrer"&gt;escape_javascript&lt;/a&gt; method.&lt;/p&gt;

&lt;p&gt;save_new_user.js.erb&lt;br&gt;
&lt;code&gt;&lt;br&gt;
$("#show_user_information").html("&amp;lt;%= escape_javascript render(partial: 'dashboard/show_user_information', locales: { user: @user }) %&amp;gt;");&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;$("#show_user_information")&lt;/strong&gt; will select the element with &lt;em&gt;id&lt;/em&gt; &lt;strong&gt;show_user_information&lt;/strong&gt; and &lt;strong&gt;html&lt;/strong&gt; will update this element with the content present in its argument. Below is the code for show_user_information partial:&lt;/p&gt;

&lt;p&gt;_show_user_information.html.erb&lt;br&gt;
`&lt;/p&gt;

&lt;p&gt;&lt;span&gt;First Name: &amp;lt;%= @user.first_name %&amp;gt;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;Last Name: &amp;lt;%= @user.last_name %&amp;gt;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;Email: &amp;lt;%= @user.email %&amp;gt;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;`&lt;/p&gt;

&lt;p&gt;So, with all this, you can enter the user information, save it in the database and then show that information on the same page without the page reload. &lt;/p&gt;

&lt;p&gt;Before submitting the form:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F59tcqfzex4r1faea5yop.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F59tcqfzex4r1faea5yop.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After form submission:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0a60c2ghro0ej8hn20lq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0a60c2ghro0ej8hn20lq.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Git rebase a remote branch in the terminal</title>
      <dc:creator>Shehroz Irfan</dc:creator>
      <pubDate>Sun, 16 Jan 2022 11:42:03 +0000</pubDate>
      <link>https://dev.to/shehrozirfan/git-rebase-a-remote-branch-in-the-terminal-4803</link>
      <guid>https://dev.to/shehrozirfan/git-rebase-a-remote-branch-in-the-terminal-4803</guid>
      <description>&lt;p&gt;Hi,&lt;br&gt;
In this article, you will learn how to git rebase a remote branch in the terminal. I am dividing the whole process of rebasing into &lt;strong&gt;5 steps&lt;/strong&gt;. Let's understand this with the example below:&lt;/p&gt;

&lt;p&gt;You are on a branch named &lt;code&gt;feature&lt;/code&gt; and you want to rebase this branch onto the branch named &lt;code&gt;main&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Step 1: Pull the latest changes from the remote of your target branch.&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In the example, the target branch(the branch onto which you want to rebase the &lt;code&gt;feature&lt;/code&gt; branch) is &lt;code&gt;main&lt;/code&gt;.&lt;br&gt;
As we are currently on &lt;code&gt;feature&lt;/code&gt;, so first we need to checkout to the &lt;code&gt;main&lt;/code&gt; and then we will pull the latest changes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git checkout main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git pull origin main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;Step 2: Rebasing &lt;code&gt;feature&lt;/code&gt; onto &lt;code&gt;main&lt;/code&gt;.&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;​&lt;br&gt;
When the pull is completed, checkout out to &lt;code&gt;feature&lt;/code&gt; and then rebase &lt;code&gt;feature&lt;/code&gt; onto &lt;code&gt;main&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git checkout feature
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git rebase main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;Step 3: Resolving Conflict&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Sometimes, rebasing a Git branch can result in conflicting changes that need to be resolved before the action can be completed.&lt;/p&gt;

&lt;p&gt;When there is a conflict in a file it looks like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs5odqwjoe9ogwmgprbfv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs5odqwjoe9ogwmgprbfv.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the above image you can see that Git adds some additional lines to the file having conflict:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; HEAD&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;=======&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; updated_address&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can think of &lt;code&gt;=======&lt;/code&gt; as the dividing line of the conflict. Everything between &lt;code&gt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; HEAD&lt;/code&gt; and &lt;code&gt;=======&lt;/code&gt; is the content of the current branch that the HEAD ref is pointing to, also called as &lt;strong&gt;Current Change&lt;/strong&gt;. On the other hand, everything between &lt;code&gt;=======&lt;/code&gt; and &lt;code&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; updated_address&lt;/code&gt; is the content in the branch being merged, also called as &lt;strong&gt;Incoming Change&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;After resolving the conflict and saving your changes, you need to tell Git that the conflict has been resolved, you can do this with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git add &amp;lt;filename&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;Step 4: Rebase Continue&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Now you can move on with the rebase by:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git rebase --continue
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So, when the rebase is completed. Your branch &lt;code&gt;feature&lt;/code&gt; is up-to-date with all changes which had been previously committed to the &lt;code&gt;main&lt;/code&gt; branch.&lt;/p&gt;

&lt;p&gt;Alternatively, if you’re unable to resolve the conflicts, or decide you don’t want to move forward with the rebase, then you can &lt;strong&gt;cancel the Git rebase action&lt;/strong&gt;, with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git rebase --abort
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now your branch is back in the state, as it was in before starting the rebase.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Step 5: Pushing rebased code to GitHub&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;As you've altered Git history, the usual git push origin will not work. You'll need to modify the command by &lt;strong&gt;"force-pushing"&lt;/strong&gt; your latest changes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git push origin feature -f
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
  </channel>
</rss>
