<?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>Forem: Shahid Siddiqui</title>
    <description>The latest articles on Forem by Shahid Siddiqui (@shahidalisiddiqui).</description>
    <link>https://forem.com/shahidalisiddiqui</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%2F423449%2F6216bdb1-d0cb-45a8-8ce7-393caf4f0671.jpg</url>
      <title>Forem: Shahid Siddiqui</title>
      <link>https://forem.com/shahidalisiddiqui</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/shahidalisiddiqui"/>
    <language>en</language>
    <item>
      <title>Beginner🌱 Git Commands</title>
      <dc:creator>Shahid Siddiqui</dc:creator>
      <pubDate>Wed, 28 Oct 2020 13:18:32 +0000</pubDate>
      <link>https://forem.com/shahidalisiddiqui/beginner-git-commands-2bpb</link>
      <guid>https://forem.com/shahidalisiddiqui/beginner-git-commands-2bpb</guid>
      <description>&lt;p&gt;Hi 👋🏻&lt;br&gt;
If you just begin your Git Journey and confused😕 with Git Commands ,Then this is for you ☺️!&lt;/p&gt;

&lt;h1&gt;
  
  
  Environment setting for Git Bash
&lt;/h1&gt;

&lt;p&gt;If you don't know Git Bash or if you haven't used git in your machine 💻 , follow these steps to get started:&lt;/p&gt;

&lt;p&gt;1.Download Git Bash for your device 💻  &lt;a href="https://git-scm.com/downloads"&gt;Git Bash&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2.Open Git Bash  by clicking the right mouse button 🖱️ for Windows user. Then set up your name📛 and email📧 ID:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git config --global user.name "&amp;lt;Your_Name&amp;gt;"

$ git config --global user.email "&amp;lt;Your_Email&amp;gt;"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;3.Go to &lt;a href="http://github.com/"&gt;GitHub&lt;/a&gt; and create your GitHub account using your email.&lt;br&gt;
  Make sure ,to use the same email📧 ,you have used earlier.&lt;/p&gt;

&lt;h3&gt;
  
  
  At this instance there are two ways to go furthur:
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;1️⃣First&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;4.Go to your desired folder📁 your you want to keep all your your GitHub repository😳. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;clone a remote repo. via URL&lt;/em&gt;&lt;/p&gt;

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

&lt;/div&gt;

&lt;p&gt;You may get URL from a online GitHub repository by Clicking on Code&lt;br&gt;
Button 🌛 of Your repository.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2️⃣Second&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;4.Go to a folder📁 which you want to make as a GitHub repository😳. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Initalize a existing directory as a git repo.&lt;/em&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;h1&gt;
  
  
  &lt;em&gt;That's all for setting ,Now begin your Code&lt;/em&gt;
&lt;/h1&gt;
&lt;h1&gt;
  
  
  🎉🎉&lt;strong&gt;Commands&lt;/strong&gt;🎉🎉
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TM3VsDu3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/8hugfatccsw4em9vqhyq.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TM3VsDu3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/8hugfatccsw4em9vqhyq.jpg" alt="Commands" width="880" height="491"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  1 :
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Below will add your modified file.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;           git add myFile
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;When you want stage your changes for &lt;strong&gt;myFile&lt;/strong&gt; file.&lt;/p&gt;

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

&lt;/div&gt;

&lt;p&gt;When you want stage your &lt;strong&gt;All modified&lt;/strong&gt; file.&lt;/p&gt;

&lt;h1&gt;
  
  
  2 :
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Below will restore your file.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

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

&lt;/div&gt;

&lt;p&gt;unstage a file while retaining the changes in working directory&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Below  will show all commits with all details like author and their email.&lt;/em&gt;&lt;/strong&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;&lt;em&gt;Below  will show  commits in compact way!,Only show commit hash and message&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

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

&lt;/div&gt;
&lt;h1&gt;
  
  
  3 :
&lt;/h1&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;           git revert &amp;lt;commit hash&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;If you want roll back your commit,You may use above command.&lt;br&gt;
you can get commit hash of all of your commit by entering command: &lt;code&gt;git log&lt;/code&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  4 :
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Below will show your current status.&lt;/em&gt;&lt;/strong&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;If you haven't staged or add it ,It will show like this&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; On branch master
   Changes not staged for commit:
   (use "git add &amp;lt;file&amp;gt;..." to update what will be committed)
   (use "git restore &amp;lt;file&amp;gt;..." to discard changes in working directory)
    modified:   abcd.md

   no changes added to commit (use "git add" and/or "git commit -a")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;If you have staged your file. Then, It will show you staged modified file for your next commit.Like this:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; On branch master
  Changes to be committed:
   (use "git restore --staged &amp;lt;file&amp;gt;..." to unstage)
    modified:   abcd.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h1&gt;
  
  
  5 :
&lt;/h1&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;            git push origin &amp;lt;branch&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;When you want to push  your final changes to remote repository in particular branch.By default ,you have master branch ,so you may&lt;br&gt;
write as:&lt;/p&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;h1&gt;
  
  
  6 :
&lt;/h1&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;When you want to pull  all changes from remote repository in your current local branch.&lt;/p&gt;

&lt;h1&gt;
  
  
  7 :
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;When you want to create branch&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

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

&lt;/div&gt;

&lt;p&gt;create a new branch name &lt;strong&gt;branch1&lt;/strong&gt; at the current commit&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;When you want to see all branches&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

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

&lt;/div&gt;

&lt;p&gt;It will list your branches. And a *  will appear next to the currently active branch like this:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;       PS D:\winter plan&amp;gt; git branch
       * branch1
         master
         one
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;When you want to switch branch&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

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

&lt;/div&gt;

&lt;p&gt;switch to another branch1 and check it out into your working directory&lt;/p&gt;

&lt;h1&gt;
  
  
  8 :
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Merge a branch into another or main&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

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

&lt;/div&gt;

&lt;p&gt;merge the branch1 history into the current one&lt;/p&gt;

&lt;p&gt;&lt;em&gt;When you want to switch branches either you need to commit your modified changes Or you may temporarly stored modified and tracked file.&lt;/em&gt;&lt;/p&gt;

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

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;above command Save modified and staged changes and below will discard  the changes from top of stash stack&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;


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

&lt;/div&gt;
&lt;h3&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Happy Gitting 💥💥&lt;br&gt;
&lt;/h3&gt;

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