<?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: Jonas Gerosa</title>
    <description>The latest articles on DEV Community by Jonas Gerosa (@jonasgerosa).</description>
    <link>https://dev.to/jonasgerosa</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%2F639508%2Fd6b2046c-fbc9-496e-8515-efa71c580b70.jpeg</url>
      <title>DEV Community: Jonas Gerosa</title>
      <link>https://dev.to/jonasgerosa</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jonasgerosa"/>
    <language>en</language>
    <item>
      <title>"Squashing" commits</title>
      <dc:creator>Jonas Gerosa</dc:creator>
      <pubDate>Tue, 01 Mar 2022 18:06:41 +0000</pubDate>
      <link>https://dev.to/jonasgerosa/squashing-commits-2h07</link>
      <guid>https://dev.to/jonasgerosa/squashing-commits-2h07</guid>
      <description>&lt;h2&gt;
  
  
  Why to squash commit?
&lt;/h2&gt;

&lt;p&gt;In this article, we will cover how to squash commits but before that let's understand why would we want to do this. The most beneficial aspect of squashing commit is during the PR review where instead of having multiple commits to check we will have only one:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PR with 4 commits&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UK_mUitR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p1djzpzrnlyy26ci2fjx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UK_mUitR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p1djzpzrnlyy26ci2fjx.png" alt="Pull Request with 4 commits" width="880" height="479"&gt;&lt;/a&gt;&lt;br&gt;
In the above example, we could have only the commit message "Created component Main".&lt;/p&gt;
&lt;h2&gt;
  
  
  Squashing the commit
&lt;/h2&gt;

&lt;p&gt;First let's check how many commits we will have to squash:&lt;br&gt;
&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_A9Ht6Fs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fxf13b4xh6kw7nwe9kxj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_A9Ht6Fs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fxf13b4xh6kw7nwe9kxj.png" alt="Git commits history" width="797" height="605"&gt;&lt;/a&gt;&lt;br&gt;
In this example, we have 4 commits in our branch develop. Let's squash them with&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git rebase -i HEAD~4&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;This will open our default editor with the following content:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pick 8bfae95 Created component Main
pick 614f223 Created style for compoent Main
pick f94c037 Bugfix on component Main
pick 5f23279 Changed some styles on component
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We have a legend explaining the options available here but for the squash just leave the first line with "pick" and change all other ones to "squash" or "s". &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DsdPmJRJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hw1i122rkwtdv55vcmbr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DsdPmJRJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hw1i122rkwtdv55vcmbr.png" alt="Git commits listed on rebase-todo" width="880" height="76"&gt;&lt;/a&gt;&lt;br&gt;
Save your file and the next file with the commit messages will appear:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WrIc-wPn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/knzdm4xyxjln5ok4bel7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WrIc-wPn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/knzdm4xyxjln5ok4bel7.png" alt="List with git commit messages" width="880" height="281"&gt;&lt;/a&gt;&lt;br&gt;
In our case we'll exclude all messages and leave only the first one:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jv3amQME--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/luiv4oz2kcbwe1ohajza.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jv3amQME--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/luiv4oz2kcbwe1ohajza.png" alt="List with git commit, now with only 1 commit message" width="880" height="136"&gt;&lt;/a&gt;&lt;br&gt;
After saving your file we now have only one commit in our local branch:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jFOrgLX2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zqt7cqnxyb8ii5porc6y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jFOrgLX2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zqt7cqnxyb8ii5porc6y.png" alt="Git log with one commit" width="723" height="308"&gt;&lt;/a&gt;&lt;br&gt;
Now let's push this to create our new PR - the -f here was used because now we are behind the remote branch:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git push origin develop -f&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;And now we have a PR with only one commit :)&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6xC_lYgM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/21yn7p4ybkrrtf1xzujj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6xC_lYgM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/21yn7p4ybkrrtf1xzujj.png" alt="PR with only one commit" width="880" height="316"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>git</category>
      <category>github</category>
    </item>
    <item>
      <title>Github: Using multiple deploy keys</title>
      <dc:creator>Jonas Gerosa</dc:creator>
      <pubDate>Sat, 20 Nov 2021 16:21:22 +0000</pubDate>
      <link>https://dev.to/jonasgerosa/github-using-multiple-deploy-keys-a82</link>
      <guid>https://dev.to/jonasgerosa/github-using-multiple-deploy-keys-a82</guid>
      <description>&lt;p&gt;&lt;strong&gt;This tutorial will cover how to use multiple deploy keys with Github on a Linux/Mac system.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The first repository with deploy key
&lt;/h2&gt;

&lt;p&gt;To use a repository with a deploy key first check if you have an id_rsa.pub file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ls -l ~/.ssh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;if there is a key created you will see a result like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ls -l ~/.ssh/
total 40
-rw------- 1 jonasg domain^users  2610 nov 20 10:26 ceep_rsa
-rw-r--r-- 1 jonasg domain^users   580 nov 20 10:26 ceep_rsa.pub
-rw-r--r-- 1 jonasg domain^users   117 nov 20 10:27 config
-rw------- 1 jonasg domain^users  3389 out  4 14:34 id_rsa
-rw-r--r-- 1 jonasg domain^users   752 out  4 14:34 id_rsa.pub
-rw-r--r-- 1 jonasg domain^users 11272 nov 19 09:42 known_hosts

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

&lt;/div&gt;



&lt;p&gt;In the example above I have 2 different keys, one id_rsa, and another ceep_rsa. Each key is composed of a rsa file and a rsa_pub file.&lt;/p&gt;

&lt;p&gt;For creating or first "deploy key" we will use the id_rsa.pub file. Copy the content of the command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cat ~/.ssh/id_rsa.pub
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And on your Github repository, access Settings / Deploy keys / Add deploy key. Past the key on the Key field, give it a name in the field Title, and check the permission to write to be able to push to this repository.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cKp51gxF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qtge1vtmadhk3xpksfxl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cKp51gxF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qtge1vtmadhk3xpksfxl.png" alt="Image of the deploy key section on Github.com" width="879" height="516"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Adding a second deploy key
&lt;/h2&gt;

&lt;p&gt;Create a new ssh key:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh-keygen 
Generating public/private rsa key pair.
Enter file in which to save the key (/home/jonasg/.ssh/id_rsa): /home/jonasg/.ssh/second_rsa
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will create a new pair of files named second_rsa and second_rsa.pub. Copy the second_rsa.pub content and paste it on Github Deploy key of the second repository on Settings / Deploy keys / Add deploy key.&lt;/p&gt;

&lt;p&gt;Now it will be necessary to create a config file for our keys:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;vi ~/.ssh/config
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And add the configuration below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Host repositoryOne.github.com
  HostName github.com
  User git
  IdentityFile /home/jonasg/.ssh/id_rsa
  IdentitiesOnly yes

Host repositoryTwo.github.com
  HostName github.com
  User git
  IdentityFile /home/jonasg/.ssh/second_rsa
  IdentitiesOnly yes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And on local git repository:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;vi "local_repository"/.git/config
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Change the value of URL replacing only the repositoryTwo part. The end result will be something like '&lt;a href="mailto:git@repositoryTwo.github.com"&gt;git@repositoryTwo.github.com&lt;/a&gt;:your-repository-path'&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        url = git@repositoryTwo.github.com:jonas-gerosa361-react/ceep.git
        fetch = +refs/heads/*:refs/remotes/origin/*
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you will be able to push to both repositories without passing user and password. For adding more repository just follow the same proccess for them.&lt;/p&gt;

&lt;p&gt;Have fun :)&lt;/p&gt;

</description>
      <category>github</category>
      <category>git</category>
    </item>
  </channel>
</rss>
