<?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: Veni</title>
    <description>The latest articles on DEV Community by Veni (@venicode).</description>
    <link>https://dev.to/venicode</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%2F2047755%2Fd10c3e7f-fd34-41a9-b347-e3570f73cefd.png</url>
      <title>DEV Community: Veni</title>
      <link>https://dev.to/venicode</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/venicode"/>
    <language>en</language>
    <item>
      <title>📚 Let's learn the main GIT commands</title>
      <dc:creator>Veni</dc:creator>
      <pubDate>Mon, 09 Sep 2024 14:38:08 +0000</pubDate>
      <link>https://dev.to/venicode/lets-learn-the-main-git-commands-33np</link>
      <guid>https://dev.to/venicode/lets-learn-the-main-git-commands-33np</guid>
      <description>&lt;p&gt;Let's simplify and review the main commands used in GIT and what each of them is for!&lt;/p&gt;

&lt;p&gt;✨ &lt;strong&gt;Initializing a repository&lt;/strong&gt;&lt;br&gt;
After installing GIT and configuration your credentials, open Git Bash by right-clicking on your project folder and type the command below:&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;✔️ &lt;strong&gt;Connecting with remote repository&lt;/strong&gt;&lt;br&gt;
To connect your local repository with the remote one:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;This link is just a example, replace with yours.&lt;/p&gt;

&lt;p&gt;⚡ &lt;strong&gt;Cloning a remote repository&lt;/strong&gt;&lt;br&gt;
If you already have a remote repository, you can just clone this into your folder:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone https://github.com/username/repository.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;➕ &lt;strong&gt;Adding files in your commit&lt;/strong&gt;&lt;br&gt;
Before do a commit, you need add your new and change files to the staging area.&lt;/p&gt;

&lt;p&gt;Adding just one file:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Adding a file that is in another folder:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git add folder/file_name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Adding all the files and changes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-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;➖ &lt;strong&gt;Removing a file in the stating area&lt;/strong&gt;&lt;br&gt;
To remove a file in the staging area (this not undo your changes in your real files project):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git restore -- staged file_name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you want remove all them:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git restore -- staged .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🔍 &lt;strong&gt;Checking status in the staging area&lt;/strong&gt;&lt;br&gt;
To check which files is already in the staging and which is not in:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-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;What's in red is the files which is not in the staging area yet:&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%2Fpiw4rh9joddbckf4wvpt.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%2Fpiw4rh9joddbckf4wvpt.png" alt="Git Status with files to add" width="800" height="197"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What's in green is the files which is in the staging area:&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%2F00ys24t65hox8piwu22h.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%2F00ys24t65hox8piwu22h.png" alt="Git Status with files already added" width="794" height="174"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And if you don't have any files to add in the staging area:&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%2F6qnvdlf6hwjr0yjb3dkk.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%2F6qnvdlf6hwjr0yjb3dkk.png" alt="Git status empty" width="794" height="130"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;📦 &lt;strong&gt;Doing a commit&lt;/strong&gt;&lt;br&gt;
To do a commit, which will prepare all the files in the staging area to be push late:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Be careful when writing a message, be sure that you are explain what the commit is for.&lt;/p&gt;

&lt;p&gt;🚀 &lt;strong&gt;Doing a push&lt;/strong&gt;&lt;br&gt;
To do a push to your remote repository:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;🔍 &lt;strong&gt;Checking your commit history&lt;/strong&gt;&lt;br&gt;
To check all commits that you did:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-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;📝 &lt;strong&gt;Updating your last commit message&lt;/strong&gt;&lt;br&gt;
To update the last commit:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git commit --amend -m "your new message here"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;↩️ &lt;strong&gt;Undoing a commit in the HEAD&lt;/strong&gt;&lt;br&gt;
To undo the last commit that was did without undo the changes in the staging area, just in the HEAD (which always point in the last commit):&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;↩️ &lt;strong&gt;Undoing a commit in the HEAD and in the staging area&lt;/strong&gt;&lt;br&gt;
To undo the last commit in the HEAD (which always point in the last commit) and the staging area:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;↩️❗ &lt;strong&gt;Undoing a commit in the HEAD, in the staging area and in your project&lt;/strong&gt;&lt;br&gt;
To undo the last commit in the HEAD (which always point in the last commit) and the staging area AND IN YOUR PROJECT:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;⬇️ &lt;strong&gt;Updating your project by pull&lt;/strong&gt;&lt;br&gt;
In case you and another person is working in the same project and you want get the changes that was did and update in your local repository:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;➕ &lt;strong&gt;Creating a new branch&lt;/strong&gt;&lt;br&gt;
To create a new branch:&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 -b branch_name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🔨 &lt;strong&gt;Swapping branches&lt;/strong&gt;&lt;br&gt;
To swap to another branch already created:&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;🔍 &lt;strong&gt;Checking the last commit in each branch&lt;/strong&gt;&lt;br&gt;
To check the last commit in each branch already created:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;❌ &lt;strong&gt;Deleting a branch&lt;/strong&gt;&lt;br&gt;
To delete a branch:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;🔀 &lt;strong&gt;Merging between two branches&lt;/strong&gt;&lt;br&gt;
Before do a merge, check if you are in the branch that will receive the update. After that, type the command below:&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 origin_branch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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