{"componentChunkName":"component---src-templates-blog-post-jsx","path":"/blogs/vcs-git&github","result":{"data":{"blog":{"frontmatter":{"title":"VCS - GIT & GITHUB","thumbnail":"blog33","date":"December 30, 2020","dsaCppCodeFile":null},"excerpt":"<div class=\"my-2 p-2\">\n              <h4>Introduction</h4>\n              <div class=\"m-2\">\n                <p>\n                  <strong>Git</strong> is a distributed version-control system\n                  for tracking changes in any set of files, originally designed\n                  for coordinating work among programmers cooperating on source\n                  code during software development. Its goals include speed,\n                  data integrity, and support for distributed, non-linear\n                  workflows\n                </p>\n                <p>\n                  <strong>GitHub</strong> is where over 56 million developers\n                  shape the future of software, together. Contribute to the open\n                  source community, manage your Git repositories, review code\n                  like a pro, track bugs and features, power your CI/CD and\n                  DevOps workflows, and secure code before you commit it.\n                </p>\n                <p class=\"text-muted\">\n                  BitBucket, GitLab are also similar to GitHub but GitHub is\n                  more popular.\n                </p>\n                <p>\n                  In simple words, GitHub is like a storage bucket for your\n                  code(projects) whereas Git is used as an interactive tool\n                  between your local pc/folders and GitHub.\n                </p>\n                <p>Git & GitHub together form the Version Control System.</p>\n              </div>\n            </div>\n            <div class=\"my-2 p-2\">\n              <h4>Uses</h4>\n              <ul class=\"pl-4\">\n                <li>Collaboration</li>\n                <li>\n                  <a href=\"/blogs/openSourceContribution\"\n                    >Open source contribution</a\n                  >\n                </li>\n                <li>Storing versions properly</li>\n                <li>Restoring previous versions</li>\n                <li>Understanding what happened</li>\n                <li>Code backup</li>\n              </ul>\n            </div>\n            <div class=\"my-2 p-2\">\n              <h4>Git Workflow</h4>\n              <div class=\"m-1\">\n                <p>A GIT Project consists of three major sections:</p>\n                <ol class=\"pl-4\">\n                  <li>\n                    <strong>Working directory: </strong>\n                    It is the directory where you add, delete and edit the files\n                    i.e. a folder on your local machine where you code your\n                    project.\n                  </li>\n                  <li>\n                    <strong>Staging area: </strong>\n                    The changes are then staged(indexed) in the staging area.\n                  </li>\n                  <li>\n                    <strong>Git directory: </strong>\n                    After you commit your changes, the snapshot of the changes\n                    made will be saved into the git directory.\n                  </li>\n                </ol>\n              </div>\n            </div>\n            <div class=\"my-2 p-2\">\n              <h4>Setup</h4>\n              <div class=\"m-2\">\n                <p>\n                  For setting up Git in your pc, head over to\n                  <a href=\"https://git-scm.com/downloads\">this link</a>,\n                  download and install the software.\n                </p>\n                <p>\n                  For setting up your GitHub, head over to\n                  <a href=\"https://github.com/\">this link</a> and sign up with\n                  new account.\n                </p>\n              </div>\n            </div>\n            <div class=\"my-2 p-2\">\n              <h4>10 Basic Git Commands</h4>\n              <div class=\"m-2\">\n                <div class=\"bg-dark text-white my-4 p-2\">\n                  <h6>1. git init</h6>\n                  <p>\n                    This command simply initializes a working directory for your\n                    project as a git repository. Make sure you are in the\n                    project directory and type the following command to\n                    initialize a new repository. <br />\n                    Ex: <code>git init</code>\n                  </p>\n                </div>\n                <div class=\"bg-dark text-white my-4 p-2\">\n                  <h6>2. git add [ filename ]</h6>\n                  <p>\n                    This command puts the desired file to the staging area for\n                    operations to be performed on it. <br />\n                    Ex: <code>git add index.html</code> <br />To add all the\n                    files to staging area: <code>git add .</code>\n                  </p>\n                </div>\n                <div class=\"bg-dark text-white my-4 p-2\">\n                  <h6>3. git commit [ options ]</h6>\n                  <p>\n                    This command records the changes made to the git repository\n                    by saving a log message together with a commit id.\n                    <br />\n                    Ex: <code>git commit -m \"First commit\"</code>\n                  </p>\n                </div>\n                <div class=\"bg-dark text-white my-4 p-2\">\n                  <h6>4. git status</h6>\n                  <p>\n                    This command is used to see the status of working tree. It\n                    shows the list of unstaged files and list of staged files\n                    that needs to be committed to GitHub. If there is nothing to\n                    be committed then it will simply show that the branch is\n                    clean.\n                    <br />\n                    Ex: <code>git status</code>\n                  </p>\n                </div>\n                <div class=\"bg-dark text-white my-4 p-2\">\n                  <h6>5. git remote add origin [ location ]</h6>\n                  <p>\n                    First of all, you should create a new repository in your\n                    GitHub account and give it a name of your choice. Head over\n                    to <a href=\"https://github.com/new\">this link</a>\n                    to create a new repo.\n                    <br />\n                    This commands adds the destination repo that your local\n                    project repository(directory) must target to i.e. it\n                    connects local to remote repository. <br />\n                    Ex:\n                    <code\n                      >git remote add origin\n                      https://github.com/username/repoName.git\n                    </code>\n                  </p>\n                </div>\n                <div class=\"bg-dark text-white my-4 p-2\">\n                  <h6>6. git branch [ branch name ]</h6>\n                  <p>\n                    It creates a new branch of your repo. You can create\n                    multiple branches for your repo also.\n                    <br />\n                    Ex:\n                    <code>git branch branch-1 </code>\n                    <br />\n                    By default you will be using the branch 'main' or 'master'.\n                  </p>\n                </div>\n                <div class=\"bg-dark text-white my-4 p-2\">\n                  <h6>7. git push origin [ branch name ]</h6>\n                  <p>\n                    This command sends all your local commits to the remote repo\n                    i.e. the repo which you have newly created on GitHub. Hence\n                    in this way, GitHub will act as a storage bucket.\n                    <br />\n                    Ex:\n                    <code>git push origin master </code> <br />\n                    (or)\n                    <code>git push origin branch-1 </code>\n                  </p>\n                </div>\n                <div class=\"bg-dark text-white my-4 p-2\">\n                  <h6>8. git clone [ location ]</h6>\n                  <p>\n                    This command creates a local working copy of an existing\n                    remote repository. It simply clones to copy and downloads\n                    the repository to your computer.\n                    <br />\n                    Ex:\n                    <code>git clone https://github.com/facebook/react </code>\n                  </p>\n                </div>\n                <div class=\"bg-dark text-white my-4 p-2\">\n                  <h6>9. git rm [ filename ]</h6>\n                  <p>\n                    If by mistake, you had pushed a file which was not suppose\n                    to be then this command is useful. We can delete the file\n                    from the project(on your remote repo) and stage the removal\n                    for commit.\n                    <br />\n                    Ex:\n                    <code>git rm secretkey.js </code>\n                  </p>\n                </div>\n                <div class=\"bg-dark text-white my-4 p-2\">\n                  <h6>10. git revert [ commit id ]</h6>\n                  <p>\n                    This command is used to revert the changes back to any of\n                    the previous version of your project.\n                    <span class=\"text-muted\">\n                    Be careful with this command and never ever accidently hit this because it might cause your app to crash even if it was working fine previously.\n                    </span>\n                    <br />\n                    Ex:\n                    <code\n                      >git revert 6eb8701365c820330a6e4615cefb4ff4b75c390c</code\n                    >\n                  </p>\n                </div>\n              </div>\n            </div>\n            <div class=\"my-2 p-2\">\n              <strong>Similar posts:</strong>\n              <a href=\"/blogs/openSourceContribution\"\n                >Open Source Contribution</a\n              >\n              |\n              <a href=\"/blogs/gettingStartedWithOCS\">Get Started With OCS</a>\n            </div>\n","html":"<div class=\"my-2 p-2\">\n              <h4>Introduction</h4>\n              <div class=\"m-2\">\n                <p>\n                  <strong>Git</strong> is a distributed version-control system\n                  for tracking changes in any set of files, originally designed\n                  for coordinating work among programmers cooperating on source\n                  code during software development. Its goals include speed,\n                  data integrity, and support for distributed, non-linear\n                  workflows\n                </p>\n                <p>\n                  <strong>GitHub</strong> is where over 56 million developers\n                  shape the future of software, together. Contribute to the open\n                  source community, manage your Git repositories, review code\n                  like a pro, track bugs and features, power your CI/CD and\n                  DevOps workflows, and secure code before you commit it.\n                </p>\n                <p class=\"text-muted\">\n                  BitBucket, GitLab are also similar to GitHub but GitHub is\n                  more popular.\n                </p>\n                <p>\n                  In simple words, GitHub is like a storage bucket for your\n                  code(projects) whereas Git is used as an interactive tool\n                  between your local pc/folders and GitHub.\n                </p>\n                <p>Git & GitHub together form the Version Control System.</p>\n              </div>\n            </div>\n            <div class=\"my-2 p-2\">\n              <h4>Uses</h4>\n              <ul class=\"pl-4\">\n                <li>Collaboration</li>\n                <li>\n                  <a href=\"/blogs/openSourceContribution\"\n                    >Open source contribution</a\n                  >\n                </li>\n                <li>Storing versions properly</li>\n                <li>Restoring previous versions</li>\n                <li>Understanding what happened</li>\n                <li>Code backup</li>\n              </ul>\n            </div>\n            <div class=\"my-2 p-2\">\n              <h4>Git Workflow</h4>\n              <div class=\"m-1\">\n                <p>A GIT Project consists of three major sections:</p>\n                <ol class=\"pl-4\">\n                  <li>\n                    <strong>Working directory: </strong>\n                    It is the directory where you add, delete and edit the files\n                    i.e. a folder on your local machine where you code your\n                    project.\n                  </li>\n                  <li>\n                    <strong>Staging area: </strong>\n                    The changes are then staged(indexed) in the staging area.\n                  </li>\n                  <li>\n                    <strong>Git directory: </strong>\n                    After you commit your changes, the snapshot of the changes\n                    made will be saved into the git directory.\n                  </li>\n                </ol>\n              </div>\n            </div>\n            <div class=\"my-2 p-2\">\n              <h4>Setup</h4>\n              <div class=\"m-2\">\n                <p>\n                  For setting up Git in your pc, head over to\n                  <a href=\"https://git-scm.com/downloads\">this link</a>,\n                  download and install the software.\n                </p>\n                <p>\n                  For setting up your GitHub, head over to\n                  <a href=\"https://github.com/\">this link</a> and sign up with\n                  new account.\n                </p>\n              </div>\n            </div>\n            <div class=\"my-2 p-2\">\n              <h4>10 Basic Git Commands</h4>\n              <div class=\"m-2\">\n                <div class=\"bg-dark text-white my-4 p-2\">\n                  <h6>1. git init</h6>\n                  <p>\n                    This command simply initializes a working directory for your\n                    project as a git repository. Make sure you are in the\n                    project directory and type the following command to\n                    initialize a new repository. <br />\n                    Ex: <code>git init</code>\n                  </p>\n                </div>\n                <div class=\"bg-dark text-white my-4 p-2\">\n                  <h6>2. git add [ filename ]</h6>\n                  <p>\n                    This command puts the desired file to the staging area for\n                    operations to be performed on it. <br />\n                    Ex: <code>git add index.html</code> <br />To add all the\n                    files to staging area: <code>git add .</code>\n                  </p>\n                </div>\n                <div class=\"bg-dark text-white my-4 p-2\">\n                  <h6>3. git commit [ options ]</h6>\n                  <p>\n                    This command records the changes made to the git repository\n                    by saving a log message together with a commit id.\n                    <br />\n                    Ex: <code>git commit -m \"First commit\"</code>\n                  </p>\n                </div>\n                <div class=\"bg-dark text-white my-4 p-2\">\n                  <h6>4. git status</h6>\n                  <p>\n                    This command is used to see the status of working tree. It\n                    shows the list of unstaged files and list of staged files\n                    that needs to be committed to GitHub. If there is nothing to\n                    be committed then it will simply show that the branch is\n                    clean.\n                    <br />\n                    Ex: <code>git status</code>\n                  </p>\n                </div>\n                <div class=\"bg-dark text-white my-4 p-2\">\n                  <h6>5. git remote add origin [ location ]</h6>\n                  <p>\n                    First of all, you should create a new repository in your\n                    GitHub account and give it a name of your choice. Head over\n                    to <a href=\"https://github.com/new\">this link</a>\n                    to create a new repo.\n                    <br />\n                    This commands adds the destination repo that your local\n                    project repository(directory) must target to i.e. it\n                    connects local to remote repository. <br />\n                    Ex:\n                    <code\n                      >git remote add origin\n                      https://github.com/username/repoName.git\n                    </code>\n                  </p>\n                </div>\n                <div class=\"bg-dark text-white my-4 p-2\">\n                  <h6>6. git branch [ branch name ]</h6>\n                  <p>\n                    It creates a new branch of your repo. You can create\n                    multiple branches for your repo also.\n                    <br />\n                    Ex:\n                    <code>git branch branch-1 </code>\n                    <br />\n                    By default you will be using the branch 'main' or 'master'.\n                  </p>\n                </div>\n                <div class=\"bg-dark text-white my-4 p-2\">\n                  <h6>7. git push origin [ branch name ]</h6>\n                  <p>\n                    This command sends all your local commits to the remote repo\n                    i.e. the repo which you have newly created on GitHub. Hence\n                    in this way, GitHub will act as a storage bucket.\n                    <br />\n                    Ex:\n                    <code>git push origin master </code> <br />\n                    (or)\n                    <code>git push origin branch-1 </code>\n                  </p>\n                </div>\n                <div class=\"bg-dark text-white my-4 p-2\">\n                  <h6>8. git clone [ location ]</h6>\n                  <p>\n                    This command creates a local working copy of an existing\n                    remote repository. It simply clones to copy and downloads\n                    the repository to your computer.\n                    <br />\n                    Ex:\n                    <code>git clone https://github.com/facebook/react </code>\n                  </p>\n                </div>\n                <div class=\"bg-dark text-white my-4 p-2\">\n                  <h6>9. git rm [ filename ]</h6>\n                  <p>\n                    If by mistake, you had pushed a file which was not suppose\n                    to be then this command is useful. We can delete the file\n                    from the project(on your remote repo) and stage the removal\n                    for commit.\n                    <br />\n                    Ex:\n                    <code>git rm secretkey.js </code>\n                  </p>\n                </div>\n                <div class=\"bg-dark text-white my-4 p-2\">\n                  <h6>10. git revert [ commit id ]</h6>\n                  <p>\n                    This command is used to revert the changes back to any of\n                    the previous version of your project.\n                    <span class=\"text-muted\">\n                    Be careful with this command and never ever accidently hit this because it might cause your app to crash even if it was working fine previously.\n                    </span>\n                    <br />\n                    Ex:\n                    <code\n                      >git revert 6eb8701365c820330a6e4615cefb4ff4b75c390c</code\n                    >\n                  </p>\n                </div>\n              </div>\n            </div>\n            <div class=\"my-2 p-2\">\n              <strong>Similar posts:</strong>\n              <a href=\"/blogs/openSourceContribution\"\n                >Open Source Contribution</a\n              >\n              |\n              <a href=\"/blogs/gettingStartedWithOCS\">Get Started With OCS</a>\n            </div>"},"thumbnail":{"childImageSharp":{"fluid":{"tracedSVG":"data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='400'%20height='225'%20viewBox='0%200%20400%20225'%20preserveAspectRatio='none'%3e%3cpath%20d='M0%20113v112h401V0H0v113m187-90v3l1%203c0%203%200%204-3%205-8%203-9%204-12%2011-6%2011-5%2019%201%2021%203%201%203%202%203%206v4h13c16%200%2017%200%2016-3-1-2%200-2%203-2s4%200%204-2l2-3c1-1%202-9%200-9l-1%203c0%202%200%202-1%201-1-2-3-3-2-1%200%202-5%203-13%203-7%201-8%200-3-1%206-2%2010-6%206-8l-2-6-3-7c-3-2-3-6%201-9%204-5%201-12-5-9h-5m-53%2069c-4%205-2%2014%202%2014s6-3%206-8c0-7-3-10-8-6m42%200c-4%205-2%2014%202%2014s6-3%206-9c0-7-3-9-8-5m48%200c-4%203-4%2014%201%2014%206%200%2010-12%204-15-2-1-2-1-5%201M81%2093c0%205%203%2013%205%2013%201%200%202-1%204-7%202-8%202-8%200-8-1%200-2%201-2%203-1%204-3%204-3%200-1-3-4-4-4-1m13%200l-1%207v6h5c4%200%205%200%205-2s-1-2-3-2l-3-1%203-1c1%200%202%200%202-2l-3-1-2-1%202-1c3%200%205-1%205-3s-10-2-10%201m12-1l-1%208c-1%205-1%206%201%206%201%200%202-1%202-3v-2l2%202c3%204%206%203%204-1v-4l1-4c0-2-1-3-5-3l-4%201m38%202l-1%207c0%205%200%205%202%205s2-1%202-4v-3l2%203c2%207%205%205%205-2l1-7c0-2%200-2-2-2s-2%201-2%203v3l-2-3c-2-4-5-4-5%200m20%200c-3%204-2%2012%202%2012%203%200%206-2%206-4s-1-3-3-1c-3%204-4-2-2-6h2c0%202%204%203%204%201%200-6-5-7-9-2m22%201l-1%207c0%204%200%204%202%204s2-1%202-4v-3l2%203c2%207%205%205%205-3%200-3%200-6%201-5l2%201c2%200%202%201%202%206l1%205c2%200%203-4%203-9%200-2%201-3%202-3l1-1c0-2-1-2-7-2h-8v6l-2-3c-2-5-5-4-5%201m24%200c-2%207-1%2011%201%2011s2-1%202-3%200-2%201-1l2%203h2c2-1%202-2%201-3v-4c2-5%200-7-5-7-4%200-4%200-4%204m41-3c-2%202-1%206%202%208s3%203%200%203c-3-1-5%201-3%202h8c2-2%201-4-1-7l-2-2h2c2%200%202%200%202-2-1-3-6-4-8-2m22%201c-1%203-1%205%202%207s2%203-1%203c-2-1-2-1-2%201%201%203%208%203%209-1%201-2%200-3-2-5l-2-3h9v5l1%206c2%200%202-1%203-6%200-4%201-6%202-6l1-1c0-2-1-2-5-2l-6%201h-1c-2-2-6-1-8%201m22-1l-1%207v7h5c4%200%205%200%205-2s-1-2-3-2l-3-1%203-1c1%200%202%200%202-2l-3-1-2-1%202-1c3%200%205-1%205-3%200-1-9-2-10%200m11%205l-1%207c0%202%200%202%202%202l2-2h5l2%202c2%200%202-1%202-7%200-9-2-11-4-5l-2%202a1526%201526%200%2000-4-5c-2%200-2%201-2%206m-161%2025c-3%201-5%2011-2%2013%204%205%208%201%208-7%200-6-2-8-6-6m8%200v8c-1%207-1%207%201%207s2-1%202-4c0-5%202-9%204-8v6c0%205%201%206%202%206%202%200%202-1%202-3%200-5%201-9%203-9l1-2c0-2-1-2-7-2l-8%201m46%201c-6%205-4%2015%202%2014%204-1%206-5%204-8v-1c1-1%201-4-1-5-2-3-2-2-5%200m9%200l-1%208c0%205%200%206%202%206%201%200%202-1%202-6%200-4%200-5%202-5s2%201%202%206c0%208%203%207%204-1%200-4%201-6%202-6l1-2c0-2-1-2-7-2-5%200-7%201-7%202m16%203c-1%209-1%2011%201%2011s2-1%202-3%201-3%202-3c1-1%201%200%201%203%200%202%200%203%202%203s2-1%202-6v-8c1-3-3-2-3%201-1%204-4%204-4%200l-1-3c-1%200-2%201-2%205m13-4c-2%203-2%2012-1%2013%205%205%2010%200%2010-8-1-8-3-8-4%200s-3%208-3%200c0-5-1-8-2-5m-59%201l-1%203-1%204c-2%204%201%207%206%207%204-1%205-1%205-3v-4l-1-2-1-4c0-2-5-3-7-1m70%203l-1%207c0%204%200%204%204%204%205%200%207-2%207-9v-5l-5-1h-5v4M46%20157c-2%201-2%203-2%205%200%208%206%2010%2019%2010%208%200%208-1%2011-3%203-4%203-9%200-12-4-3-24-3-28%200m18%2032l1%203c1%203%201%203-2%202l-2-3-1-2-1%201c0%202-3%205-4%205l-1-1c2-5%202-6%200-3l-4%202c-2%200-2%200%200-2%201-2%201-2-2-1-10%202-11%208%200%2011h25c11-3%2010-9-1-12-3%200-3%200-2%201l1%203c-1%201-5-1-6-3l-1-1'%20fill='%23d3d3d3'%20fill-rule='evenodd'/%3e%3c/svg%3e","aspectRatio":1.7699115044247788,"src":"/static/5a4c179ac8d4d967dc958630906b1aa1/ee604/blog33.png","srcSet":"/static/5a4c179ac8d4d967dc958630906b1aa1/69585/blog33.png 200w,\n/static/5a4c179ac8d4d967dc958630906b1aa1/497c6/blog33.png 400w,\n/static/5a4c179ac8d4d967dc958630906b1aa1/ee604/blog33.png 800w,\n/static/5a4c179ac8d4d967dc958630906b1aa1/f3583/blog33.png 1200w,\n/static/5a4c179ac8d4d967dc958630906b1aa1/e4d72/blog33.png 1280w","sizes":"(max-width: 800px) 100vw, 800px"}}}},"pageContext":{"blog":"vcs-git&github","thumbnail":"thumbnails/blog33.png"}},"staticQueryHashes":["2987289216","63159454"]}