<?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: rulo4</title>
    <description>The latest articles on DEV Community by rulo4 (@rulo4).</description>
    <link>https://dev.to/rulo4</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%2F1147107%2F05f5b1bd-0764-48da-86c9-792a886f2dc6.jpeg</url>
      <title>DEV Community: rulo4</title>
      <link>https://dev.to/rulo4</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rulo4"/>
    <language>en</language>
    <item>
      <title>bash aliases for long or repetitive commands</title>
      <dc:creator>rulo4</dc:creator>
      <pubDate>Sun, 27 Aug 2023 02:41:21 +0000</pubDate>
      <link>https://dev.to/rulo4/bash-aliases-for-long-or-repetitive-commands-3ndn</link>
      <guid>https://dev.to/rulo4/bash-aliases-for-long-or-repetitive-commands-3ndn</guid>
      <description>&lt;p&gt;There are some reasons that I have to create aliases for commands:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Too long command&lt;/li&gt;
&lt;li&gt;Too frequently used command&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are some of them:&lt;/p&gt;

&lt;h2&gt;
  
  
  For git
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;alias master='git checkout master'

alias pull='git pull'

alias sts='git status'

alias gitp='git push -u origin "$(git branch --show-current)"'

alias glog='git log --format="%C(yellow) %h %C(cyan) %ci %C(magenta) %&amp;lt;(20,trunc) %cn %&amp;gt;(10,trunc) %cl %Cgreen %s" --name-status'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  For maven
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;alias mci='mvn clean install'

alias mcis='mvn clean install -DskipTests'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To be used, we need to add them at the end of the &lt;code&gt;.bashrc&lt;/code&gt; file located in the home directory.&lt;/p&gt;

</description>
      <category>bash</category>
      <category>alias</category>
      <category>cli</category>
      <category>bashrc</category>
    </item>
    <item>
      <title>git rebase and git revert to fix the broken application.</title>
      <dc:creator>rulo4</dc:creator>
      <pubDate>Sun, 27 Aug 2023 02:12:10 +0000</pubDate>
      <link>https://dev.to/rulo4/git-rebase-and-git-revert-to-fix-the-broken-application-1hcb</link>
      <guid>https://dev.to/rulo4/git-rebase-and-git-revert-to-fix-the-broken-application-1hcb</guid>
      <description>&lt;p&gt;We realized that some previous changes merged to the remote master branch are breaking the application functionality, so we need to do something to fix it. Let's see two ways of do it.&lt;/p&gt;

&lt;h2&gt;
  
  
  git rebase: rewriting the history
&lt;/h2&gt;

&lt;p&gt;This solution can be applied only when we are allowed to delete the remote master branch and create it again.&lt;/p&gt;

&lt;p&gt;This is the initial git log (&lt;a href="https://dev.to/rulo4/bash-aliases-for-long-or-repetitive-commands-3ndn"&gt;WTF is glog?&lt;/a&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ glog

 501da39  2023-08-26 19:28:44 -0600   rulo4       raul4  commit4

A       commit4
 f216419  2023-08-26 19:28:36 -0600   rulo4       raul4  commit3

A       commit3
 a27a902  2023-08-26 19:28:29 -0600   rulo4       raul4  commit2

A       commit2
 765df57  2023-08-26 19:28:17 -0600   rulo4       raul4  commit1

A       commit1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;commit3&lt;/strong&gt; contains the changes that broke the app, so we need to &lt;strong&gt;rebase on top of the commit2&lt;/strong&gt;.&lt;br&gt;
This means that for the commits after commit2, we are going to select which of them we keep and which ones not.&lt;/p&gt;
&lt;h4&gt;
  
  
  1. create a work branch:
&lt;/h4&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git checkout -b branch-for-rebase

Switched to a new branch 'branch-for-rebase'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h4&gt;
  
  
  2. Tell git that want to rebase on top of commit2 (using the commit2 id):
&lt;/h4&gt;


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

&lt;/div&gt;


&lt;p&gt;A file named &lt;code&gt;.git/rebase-merge/git-rebase-todo&lt;/code&gt; will be opened listing all commits after commit2, starting by the oldest. Each commit is shown with &lt;strong&gt;pick&lt;/strong&gt; action by default, means that the commit will be included in the resulting history:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pick f216419 commit3
pick 501da39 commit4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  3. We need to change from pick to &lt;strong&gt;drop&lt;/strong&gt; all the bad commits to be removed from the history, in this case is the commit3. Then, the file should look as follows:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;drop f216419 commit3
pick 501da39 commit4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, after saving changes and closing the file, a message will be shown:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Successfully rebased and updated refs/heads/branch-for-rebase.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  4. Let's see again the git log and verify that the commit3 with the bad code is not in the history, is like if never existed:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ glog

 2c3d846  2023-08-26 19:48:52 -0600   rulo4       raul4  commit4

A       commit4
 a27a902  2023-08-26 19:28:29 -0600   rulo4       raul4  commit2

A       commit2
 765df57  2023-08-26 19:28:17 -0600   rulo4       raul4  commit1

A       commit1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So, now the remote master branch can be deleted, and we can recreate it again from our work branch.&lt;/p&gt;

&lt;h2&gt;
  
  
  git revert: fixing errors keeping them in the history
&lt;/h2&gt;

&lt;p&gt;We can use this method when is not possible for us to change the remote master branch, in other words we cannot change the history.&lt;/p&gt;

&lt;p&gt;Let's start by seeing again the original history:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ glog

 501da39  2023-08-26 19:28:44 -0600   rulo4       raul4  commit4

A       commit4
 f216419  2023-08-26 19:28:36 -0600   rulo4       raul4  commit3

A       commit3
 a27a902  2023-08-26 19:28:29 -0600   rulo4       raul4  commit2

A       commit2
 765df57  2023-08-26 19:28:17 -0600   rulo4       raul4  commit1

A       commit1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  1. Create the branch to do the revert:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git checkout -b branch-for-revert

Switched to a new branch 'branch-for-revert'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  2. Tell to git that want to revert the commit3, as this is the one with bad code:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git revert f216419
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A file named &lt;code&gt;.git/COMMIT_EDITMSG&lt;/code&gt; is opened, indicating the changes to be reverted:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Revert "commit3"

This reverts commit f216419653ce9cd1a5562d3ba61b8eb0a1a956c7.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  3. After closing the previous file, a summary of the changes will be shown:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[branch-for-revert 6d8db03] Revert "commit3"
 1 file changed, 0 insertions(+), 0 deletions(-)
 delete mode 100644 commit3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  4. Let's see again the git log and verify that the commit3 with the bad code is still there in the history, but another commit was added to revert it:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ glog

 6d8db03  2023-08-26 20:04:44 -0600   rulo4  raul4  Revert "commit3"

D       commit3
 501da39  2023-08-26 19:28:44 -0600   rulo4   aul4  commit4

A       commit4
 f216419  2023-08-26 19:28:36 -0600   rulo4  raul4  commit3

A       commit3
 a27a902  2023-08-26 19:28:29 -0600   rulo4  raul4  commit2

A       commit2
 765df57  2023-08-26 19:28:17 -0600   rulo4  raul4  commit1

A       commit1

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So, we can proceed to create a pull request from our work branch to the remote master branch.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final words
&lt;/h2&gt;

&lt;p&gt;This is clearly a too simple example where no conflicts are required to be solved, the intention is to understand the basic concepts.&lt;/p&gt;

</description>
      <category>git</category>
      <category>rebase</category>
      <category>revert</category>
      <category>versioning</category>
    </item>
  </channel>
</rss>
