<?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: Itziar Urbieta León</title>
    <description>The latest articles on DEV Community by Itziar Urbieta León (@thisisitz).</description>
    <link>https://dev.to/thisisitz</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%2F334633%2F0027de3a-21af-4839-a126-02ef500ab51e.jpg</url>
      <title>DEV Community: Itziar Urbieta León</title>
      <link>https://dev.to/thisisitz</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/thisisitz"/>
    <language>en</language>
    <item>
      <title>Git basics</title>
      <dc:creator>Itziar Urbieta León</dc:creator>
      <pubDate>Mon, 04 May 2020 10:40:46 +0000</pubDate>
      <link>https://dev.to/thisisitz/git-basics-5808</link>
      <guid>https://dev.to/thisisitz/git-basics-5808</guid>
      <description>&lt;h1&gt;
  
  
  Git basics
&lt;/h1&gt;

&lt;p&gt;Git is a Version Control System known by almost all programmers or even all of them. It manages all the changes made to your files and projects in an easy way. So is important to know how it works.&lt;/p&gt;

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

&lt;p&gt;Git is a Version Control System. It means that git is going to help you to store and manage all the changes that you make to your file or project through the time. To do this, git works with repositories, and you have to commit those changes. Git runs on your local machine so you don’t need to have an internet connection.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to start using git
&lt;/h2&gt;

&lt;p&gt;First of all, you need to install Git on your local computer. You can download it from &lt;a href="https://git-scm.com/"&gt;its website.&lt;/a&gt;&lt;br&gt;
When you have already installed Git, you have to get into your Project folder&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd projectFolder
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;or you can create an empty directory for your project using&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir projectFolder
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;and then, run the command&lt;br&gt;
&lt;/p&gt;

&lt;div class="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;This command will initialize a Git repository in this directory.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a repository?
&lt;/h2&gt;

&lt;p&gt;A repository contains all the history of changes. It contains all the files managed by git. There are three principal local states related to files managed by git:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Working directory&lt;/li&gt;
&lt;li&gt;Staging area&lt;/li&gt;
&lt;li&gt;Git repository&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Working directory is the directory in our computer which holds all our application files and folders.&lt;br&gt;
Git repository contains all the changes that we save in git, that are finalized and uploaded by a commit.&lt;br&gt;
The staging area is in between, is a holding area, a kind of queue when we are waiting for the changes for the next commit.&lt;/p&gt;
&lt;h2&gt;
  
  
  So, how can I add the changes that I’ve made to the staging area?
&lt;/h2&gt;

&lt;p&gt;Simply, using the next command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git add myFile.txt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You can use this command followed by the name of the file that you want to add to this area or you can use a folder path that allows us to add all the files at the same time. This is&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git add .
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We haven't committed our changes yet. In this area, you can move the files in and out without modify the git repository and review all the changes you have made before committing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Committing changes
&lt;/h2&gt;

&lt;p&gt;Once we have our files in the staging area we can save them in our git repo. We'll have to use another command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git commit -m "Commit message"
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;When we make a commit, we are going to save the changes in all files that were in the staging area.&lt;br&gt;
Commit messages are messages that we add to our commits to describe which kind of changes you have done. These messages have to be simples.&lt;/p&gt;
&lt;h2&gt;
  
  
  How could I know the state of my repository?
&lt;/h2&gt;

&lt;p&gt;Using the next command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git status
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Shows the status in both the working directory and staging area. It helps us to see in which state are the files you have modified so we can handle them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Can I see all the commits I have made?
&lt;/h2&gt;

&lt;p&gt;Yes! There is a command that outputs the history of changes. We have to use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git log
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This returns to us very important information about our commit history, like the ID of the commits, the author, the date and where is the head.&lt;br&gt;
It maybe looks a little confusing if you have multiples commits, but there are a few options that you can use to have a better vision of this log. My favorite one is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git log --all --decorate --oneline --graph
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This one, in particular, draws a graphical representation in one line and it's very visual. Try it yourself!&lt;/p&gt;

&lt;h1&gt;
  
  
  Found a typo?
&lt;/h1&gt;

&lt;p&gt;If you've found a typo, a sentence that could be improved or anything else that should be updated on this blog post, you can access it through a git repository and make a pull request. Instead of posting a comment, please go directly to &lt;a href="https://github.com/ThisIsItz/ThisIsDev"&gt;my git repository&lt;/a&gt; and open a new pull request with your changes.&lt;/p&gt;

</description>
      <category>git</category>
      <category>begginers</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
