<?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: Heloisa Louzada B. Gomes</title>
    <description>The latest articles on DEV Community by Heloisa Louzada B. Gomes (@heloisalouzada).</description>
    <link>https://dev.to/heloisalouzada</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%2F2091943%2F8b42911e-d73d-46de-b09d-c0b03c432a57.jpeg</url>
      <title>DEV Community: Heloisa Louzada B. Gomes</title>
      <link>https://dev.to/heloisalouzada</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/heloisalouzada"/>
    <language>en</language>
    <item>
      <title>Introduction to Git Merge</title>
      <dc:creator>Heloisa Louzada B. Gomes</dc:creator>
      <pubDate>Fri, 20 Sep 2024 13:29:54 +0000</pubDate>
      <link>https://dev.to/ledsifes/introduction-to-git-merge-5598</link>
      <guid>https://dev.to/ledsifes/introduction-to-git-merge-5598</guid>
      <description>&lt;p&gt;In this post, we will talk about an essential process in project development: the merge. Merge means "to combine," that is, the action of merging two lines of development in a project.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is the "Head"?
&lt;/h2&gt;

&lt;p&gt;Before explaining merge, it is important to understand the concept of the head. The head is a pointer that always points to the version of the code currently being worked on. When a merge is performed, the head moves to reflect the combined changes between the branches.&lt;/p&gt;

&lt;h2&gt;
  
  
  Merge Strategies
&lt;/h2&gt;

&lt;p&gt;There are different merge strategies. Let's cover the main ones:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fast-Forward&lt;/strong&gt;: The simplest strategy. The system just moves the pointer forward without conflicts. This happens when, after creating a new branch, all commits and changes were made exclusively in it. Thus, when performing the merge, there are no divergences between the main branch (master) and the new branch.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Ort&lt;/strong&gt;: This strategy is used when there are changes in both the main branch and the created branch, but in different files, without causing conflicts. Git detects that the files are in different stages but can merge the changes automatically without manual intervention.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Handling Conflicts&lt;/strong&gt;&lt;br&gt;
When a conflict occurs during the merge, the changes need to be handled manually. When using VSCode, for example, a new tab opens so you can intuitively choose how to resolve the conflicts and continue with the project.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Step by step&lt;/strong&gt;&lt;br&gt;
First, you need to be on the branch where you want to combine the changes. To do this, use 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;git checkout [branch name]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, you can merge the auxiliary branch with the target branch. Use 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;git merge [branch name]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Pratical Exemple:&lt;/strong&gt; If you are on a branch called &lt;code&gt;auxiliary_branch&lt;/code&gt; and you want to merge it with the &lt;code&gt;master&lt;/code&gt; branch, execute:&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 master
git merge auxiliar_branch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the changes from &lt;code&gt;auxiliary_branch&lt;/code&gt; are now integrated into &lt;code&gt;master&lt;/code&gt;. &lt;strong&gt;Always check that you are on the correct branch before merging&lt;/strong&gt; to avoid unwanted conflicts.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>programming</category>
      <category>tutorial</category>
      <category>github</category>
    </item>
    <item>
      <title>Introduction to "branch"</title>
      <dc:creator>Heloisa Louzada B. Gomes</dc:creator>
      <pubDate>Thu, 19 Sep 2024 14:51:41 +0000</pubDate>
      <link>https://dev.to/ledsifes/introducao-sobre-branch-3pmn</link>
      <guid>https://dev.to/ledsifes/introducao-sobre-branch-3pmn</guid>
      <description>&lt;p&gt;Today, we’re going to talk about an essential concept for using Git and GitHub: branches. For this post, we’ll assume you are already familiar with the concepts of remote repository, local repository, stage, and commit; that you have already installed Git on your machine and created an account on &lt;a href="https://github.com/" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;. If you're not familiar with these concepts, check out the introductory post about Git in the following link (&lt;a href="https://dev.to/ledscolatina/initial-introduction-to-git-and-github-4apc"&gt;https://dev.to/ledscolatina/initial-introduction-to-git-and-github-4apc&lt;/a&gt;).&lt;/p&gt;

&lt;h2&gt;
  
  
  What are Branches?
&lt;/h2&gt;

&lt;p&gt;A branch is essentially an independent environment where your commits are organized. Simplified, you can think of branches as parallel timelines where changes are made without interfering with others. Imagine the "multiverse" concept from Spider-Man: each version of the hero has its own timeline, and their actions do not affect the others, but when merged, they can create conflicts. Similarly, branches are separate environments where you can work without affecting the main code.&lt;/p&gt;

&lt;h2&gt;
  
  
  How do Branches Work?
&lt;/h2&gt;

&lt;p&gt;When a project is created, it typically starts with a branch called master (or main, in the case of a clone), which is where the main code is maintained. If you want to add new features without compromising the existing functional code, the best practice is to create a new branch. This way, you can make commits and tests without affecting the main branch until everything is ready to be integrated (or even discarded, if necessary).&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating a Branch
&lt;/h2&gt;

&lt;p&gt;Let's imagine that you are starting a project in your local repository and then plan to push it to a remote repository.&lt;/p&gt;

&lt;p&gt;When you start the project with &lt;code&gt;git init&lt;/code&gt;, Git automatically creates a main branch for you, called &lt;code&gt;master&lt;/code&gt; (or &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 init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;From this point, you can add files and make commits as usual. They will be recorded on the &lt;code&gt;master&lt;/code&gt; branch, as if they were steps in a continuous timeline.&lt;/p&gt;

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

&lt;p&gt;When the project is ready to be pushed to the remote repository on GitHub, we will start the step of linking the local repository to the remote one. To do this, you need to have a GitHub account and use some specific commands:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a new repository on your GitHub account.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;Select the "&amp;lt;&amp;gt; Code" button and copy the URL of your remote repository.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;In the git terminal, use the command &lt;code&gt;git remote add origin [remote repository URL]&lt;/code&gt; to link your local repository to the remote one.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git remote add origin https://github/user/repository_name.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;To push your files to the remote repository, use a variation of the &lt;code&gt;git push&lt;/code&gt; command. Since the repository was not cloned and we need to connect it to the remote repository, you need to specify the name of the branch you want to push, as the newly created repository does not yet have any bran
ches. The command is: &lt;code&gt;git push origin [branch-name]&lt;/code&gt;.
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Navigating Between Branches
&lt;/h2&gt;

&lt;p&gt;Next, let's start a new branch. This allows you to work on a separate branch where your changes won't affect what has already been done on the main branch.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To create a new branch, use the command &lt;code&gt;git branch [branch-name]&lt;/code&gt;.
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;If you want to create and immediately switch to the new branch, use &lt;code&gt;git checkout -b [branch-name]&lt;/code&gt;.
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;



&lt;p&gt;In this way, the files and commits added to this new branch will not be visible on the &lt;code&gt;master&lt;/code&gt; branch, and vice versa. &lt;/p&gt;

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

&lt;p&gt;To switch between branches, simply use the command &lt;code&gt;git checkout [branch-name]&lt;/code&gt;. This is useful when you need to quickly switch between different parts of the project.&lt;/p&gt;




&lt;h2&gt;
  
  
  Finalizing: Merge
&lt;/h2&gt;

&lt;p&gt;Suppose your modifications were successful, and now you want to integrate the new features into the main branch. For this, a powerful concept called &lt;strong&gt;merge&lt;/strong&gt; comes into play. Want to know how it works? Stay tuned for the next post!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/ledscolatina/introduction-to-git-merge-5598"&gt;Post about merge =D&lt;/a&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>programming</category>
      <category>tutorial</category>
      <category>github</category>
    </item>
  </channel>
</rss>
