<?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: Denise</title>
    <description>The latest articles on DEV Community by Denise (@denimartn).</description>
    <link>https://dev.to/denimartn</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%2F598129%2F565aa3f1-120a-42ac-b7f8-3024ec589ab9.jpeg</url>
      <title>DEV Community: Denise</title>
      <link>https://dev.to/denimartn</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/denimartn"/>
    <language>en</language>
    <item>
      <title>My journey in learning git basics 🧗🏻‍♀️</title>
      <dc:creator>Denise</dc:creator>
      <pubDate>Thu, 18 Mar 2021 17:30:48 +0000</pubDate>
      <link>https://dev.to/denimartn/my-journey-in-learning-git-basics-597i</link>
      <guid>https://dev.to/denimartn/my-journey-in-learning-git-basics-597i</guid>
      <description>&lt;p&gt;Git is the most popular version control tool. If you are currently working as a software developer, you probably use it on a daily basis, and if you are looking for a new job, you will definitely need to know it to work with your team.&lt;/p&gt;

&lt;p&gt;As a beginner in the web development world, I wrote this article both to help you and me clarify some basic git concepts.&lt;/p&gt;

&lt;p&gt;Here's a simple overview. 😊&lt;/p&gt;

&lt;h1&gt;
  
  
  Short introduction
&lt;/h1&gt;

&lt;h3&gt;
  
  
  What is git?
&lt;/h3&gt;

&lt;p&gt;Git is a &lt;strong&gt;version control system&lt;/strong&gt; (there are several, git is just the most popular) that helps people to collaborate on a project. &lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;version control system&lt;/strong&gt; is a software that tracks all the changes that have been made to the source code of a project. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Git&lt;/strong&gt; is able to track not only &lt;em&gt;which&lt;/em&gt; change has been made (e.g. someone changed the button’s color on a specific file), but also &lt;em&gt;who&lt;/em&gt; made it and &lt;em&gt;when&lt;/em&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why git is so useful?
&lt;/h3&gt;

&lt;p&gt;Git is useful because it allows everyone to work on a project without the fear of compromising the stable version of its code.&lt;/p&gt;

&lt;p&gt;You can work on a specific issue or bug, roll back to previous changes, and have multiple versions of the same codebase. &lt;/p&gt;

&lt;p&gt;Here’s an example:&lt;/p&gt;

&lt;p&gt;Let’s suppose you want to change your application’s theme, but you do not want to touch the source code. To do that, you can create a &lt;strong&gt;new branch&lt;/strong&gt; (imagine it as a new story of the whole project), change the theme, and then &lt;strong&gt;merge&lt;/strong&gt; (apply) the changes you made on that branch on the stable code.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is a git repository?
&lt;/h3&gt;

&lt;p&gt;A git repository is the &lt;strong&gt;.git&lt;/strong&gt; folder inside your current folder. It tracks all the changes you make within the project’s files (e.g. all the information about the commits, in which branch you are etc). &lt;/p&gt;

&lt;h1&gt;
  
  
  Basic commands
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;git init&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Create a &lt;strong&gt;.git repository&lt;/strong&gt;. You have to run this command in order to use git.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git clone&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Clone (download) an existing repository from a git server (e.g. GitHub), and put it on your local machine. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;git add&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Add a file to the &lt;strong&gt;staging area&lt;/strong&gt;. &lt;br&gt;
The &lt;strong&gt;staging area&lt;/strong&gt; is the place where a modified file stays before it’s committed.&lt;/p&gt;

&lt;p&gt;Here's a scenario:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You modify a file called &lt;em&gt;message.txt&lt;/em&gt; (this file is &lt;strong&gt;untracked&lt;/strong&gt;, a.k.a git is not aware of it);&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You add &lt;em&gt;message.txt&lt;/em&gt; to the staging area;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You commit, so you "move" &lt;em&gt;message.txt&lt;/em&gt; and all the other files that are tracked from the &lt;strong&gt;staging area&lt;/strong&gt; to the &lt;strong&gt;commit history&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;git commit&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Take all the changes and “save” them by giving a unique identifier (the identifier is created by an algorithm called SHA-1)&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git status&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Tells you about the status of your current repo:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;In which branch you are;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Changes that are not staged yet (you modified a file but you did not add it to the staging area);&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Changes that are not committed yet (you added a file to the staging area, but you did not commit yet);&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Changes are staged and committed.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;Tells you about the commit’s history:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Commit’s identifier (e.g. 00b12a46b9cf97324a59266d2721d41eb98621ff);&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Commit’s author (e.g. magicmario);&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Commit’s date (e.g. Tue Mar 16 18:25:35 2021 +0100);&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Commit’s description (e.g. change: button color on main.html).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;git branch&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Give you a list of all the branches in your repository. It is used also to create and delete a specific branch.&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;branch&lt;/strong&gt; is an &lt;em&gt;independent development history&lt;/em&gt; and is usually used to develop new features or work on bugs separately. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;git merge&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Join two branches (development histories) together and create a commit for the updated changes.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git fetch&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Download all the latest data from the remote repository to your local repo. &lt;strong&gt;Important&lt;/strong&gt;: it does not put these data into your files.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git pull&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Retrieve (fetch) information from the remote repository &lt;strong&gt;and&lt;/strong&gt; apply (merge) these to your local branch. Basically is the combination of these two commands: &lt;code&gt;git fetch&lt;/code&gt; and &lt;code&gt;git merge&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git push&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Upload your work to the remote repository (online).&lt;/p&gt;

&lt;p&gt;Source: the internet. 🌌&lt;/p&gt;

&lt;p&gt;Any feedback is welcomed!&lt;/p&gt;

&lt;p&gt;Thank you (:&lt;/p&gt;

</description>
      <category>git</category>
      <category>beginners</category>
      <category>webdev</category>
      <category>frontend</category>
    </item>
  </channel>
</rss>
