{"id":307,"date":"2018-02-03T10:00:58","date_gmt":"2018-02-03T10:00:58","guid":{"rendered":"http:\/\/www.tco-team.com\/blog\/?p=307"},"modified":"2018-02-28T12:32:40","modified_gmt":"2018-02-28T12:32:40","slug":"version-control-git","status":"publish","type":"post","link":"https:\/\/tco.am\/blog\/version-control-git\/","title":{"rendered":"Version Control &#8211; Git"},"content":{"rendered":"<p>As described in the <a href=\"http:\/\/www.tco-team.com\/blog\/importance-of-version-control\" target=\"_blank\" rel=\"noopener\">previous article<\/a>, version control can be very helpful during the development of an application. One of the most popular version control software is Git. In this post we will try to explain the usefulness of Git and describe how it can aid the development process.<\/p>\n<p style=\"float: right;\"><!--more--><\/p>\n<p>Before starting to experiment the amazing features of git, let&#8217;s imagine a situation. Let&#8217;s assume, that we have a team consisting of 3 developers, a team leader and a quality assurance engineer. The daily routine of the development team is as follows:<\/p>\n<ul>\n<li>Each developer works on a separate task<\/li>\n<li>The team lead reviews the code, checks for errors or inconsistency and approves the developers work<\/li>\n<li>QA engineer tests the application and reports if any bugs are spotted<\/li>\n<\/ul>\n<p>This is a common scenario for most of development teams and studios. Now a question arises: how to make sure, that after a developer finishes the task, it will work exactly as it is supposed to for the other developers, and how to keep track of changes from other developers? For this common situation, there is a common strategy with Git.<\/p>\n<p>First of all, it&#8217;s important to understand how Git works. Git software needs to be installed for each developer locally: there are installation packages for all popular <a href=\"http:\/\/www.tco-team.com\/blog\/operating-systems\/\" target=\"_blank\" rel=\"noopener\">operating systems<\/a>, and it&#8217;s a casual procedure of installing. In order to &#8220;share&#8221; the code between the developers, there needs to be an online server, which will allow viewing and browsing of the project codes. For that, there are open-source packages that can be installed on the private servers, or You could use a third-party services, that are giving You it already configured, which are called Git hostings. Most popular Git hostings are <a href=\"https:\/\/github.com\" target=\"_blank\" rel=\"noopener\">Github<\/a>, <a href=\"https:\/\/bitbucket.org\" target=\"_blank\" rel=\"noopener\">BitBucket<\/a> and <a href=\"https:\/\/about.gitlab.com\/\" target=\"_blank\" rel=\"noopener\">GitLab<\/a>. As for development environment, the code copy that resides on the developers&#8217; computer is called\u00a0<em>local<\/em> and the online copy, which is accessible by all the team members, is called\u00a0<em>remote<\/em>.<\/p>\n<p>So now that we understand the <em>local<\/em> \/ <em>remote<\/em> thing let&#8217;s get back to our imaginary team, which must have already done some tasks. So let&#8217;s say that all three developers have completed their assigned tasks, and want the team lead to check their work. In order for this to be possible (with the least hassle possible), they need to create a &#8220;snapshot&#8221; of their work, that will indicate who has done the changes. when the changes were done and what is this &#8220;snapshot&#8221; all about. For this,\u00a0 the developer\u00a0writes a title and description for the changes made, and <em>commits\u00a0<\/em>it.\u00a0<em>Commit <\/em>is the term used to indicate the specific <em>&#8220;<\/em>snapshot&#8221; in the history of the changes. After the developers have\u00a0<em>commited <\/em>the changes, they need to &#8220;upload&#8221; their work to the online \/\u00a0remote. This process is called <em>pushing.\u00a0<\/em><\/p>\n<p>But You may ask Yourself: <em>&#8220;Okay, I <strong>pushed <\/strong>my changes,\u00a0but how will I have the changes that made the other developer, so I will not have to do re-do the same thing for myself&#8230; To space with this, better grab a flash drive to copy those changes&#8230;&#8221;.\u00a0<\/em><\/p>\n<div class=\"text-center\"><img loading=\"lazy\" class=\"alignnone wp-image-321 size-full\" src=\"http:\/\/www.tco-team.com\/blog\/wp-content\/uploads\/2018\/02\/versioncontrol.png\" alt=\"\" width=\"650\" height=\"205\" srcset=\"https:\/\/tco.am\/blog\/wp-content\/uploads\/2018\/02\/versioncontrol.png 650w, https:\/\/tco.am\/blog\/wp-content\/uploads\/2018\/02\/versioncontrol-150x47.png 150w\" sizes=\"(max-width: 650px) 100vw, 650px\" \/><\/div>\n<p>Git wouldn&#8217;t be Git if it did not give a solution from this, so please, put back the flash drive, we are not going to need that. For that You will need to &#8220;download&#8221; the code from the <em>remote<\/em>. This process is called\u00a0<em>pulling<\/em>.<\/p>\n<div class=\"row\">\n<div class=\"col-sm-3\"><img loading=\"lazy\" class=\"alignnone size-thumbnail wp-image-316\" src=\"http:\/\/www.tco-team.com\/blog\/wp-content\/uploads\/2018\/02\/push-150x58.png\" alt=\"\" width=\"150\" height=\"58\" srcset=\"https:\/\/tco.am\/blog\/wp-content\/uploads\/2018\/02\/push-150x58.png 150w, https:\/\/tco.am\/blog\/wp-content\/uploads\/2018\/02\/push.png 376w\" sizes=\"(max-width: 150px) 100vw, 150px\" \/><\/div>\n<div class=\"col-sm-6\">So the basic <em>ritual<\/em> of using Git is\u00a0<em>pushing\u00a0<\/em>Your changes to the server, and\u00a0<em>pull<\/em> the changes that the other developer has done.<\/div>\n<div class=\"col-sm-3\"><img loading=\"lazy\" class=\"alignnone size-thumbnail wp-image-317\" src=\"http:\/\/www.tco-team.com\/blog\/wp-content\/uploads\/2018\/02\/pull-150x58.png\" alt=\"\" width=\"150\" height=\"58\" srcset=\"https:\/\/tco.am\/blog\/wp-content\/uploads\/2018\/02\/pull-150x58.png 150w, https:\/\/tco.am\/blog\/wp-content\/uploads\/2018\/02\/pull.png 376w\" sizes=\"(max-width: 150px) 100vw, 150px\" \/><\/div>\n<\/div>\n<p>Now that You know what is all about the pull-push programmers&#8217; trend, then let&#8217;s catch up with our imaginary team. By now, the team lead should&#8217;ve already reviewed the developers&#8217; code and notified the developers about the problems he found and made some improvements to the code, because that query was killing the database with it&#8217;s\u00a0<strong><em>1753<\/em><\/strong><em>\u00a0<\/em>consecutive requests&#8230;<\/p>\n<p>So the developer needs to\u00a0<em>pull\u00a0<\/em>the changes to get the team lead&#8217;s improvements, fix the problems team lead wrote, and do a <em>commit<\/em> again, and after that <em>push<\/em> to the <em>remote<\/em>.<\/p>\n<p>After all this problems are fixed and the changes are approved, the application gets deployed to a test server, where the QA engineer can test the functionality and report issues and repeat the\u00a0<em>pull-push<\/em> cycle if necessary.<\/p>\n<p>&nbsp;<\/p>\n<p>We will discuss more complex scenarios in the next articles and examine the power of Git in practice, so stay tuned to our blog to get more information about Git, version control systems and other interesting subjects.<\/p>\n<p>&nbsp;<\/p>\n<p>External Links:<\/p>\n<p><a href=\"https:\/\/git-scm.com\/book\/en\/v2\/Getting-Started-Installing-Git\" target=\"_blank\" rel=\"noopener\">How to install Git<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>As described in the previous article, version control can be very helpful during the development of an application. One of the most popular version control software is Git. In this post we will try to explain the usefulness of Git and describe how it can aid the development process.<\/p>\n","protected":false},"author":1,"featured_media":325,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[37],"tags":[94,95,90,93,96,97,91,92],"_links":{"self":[{"href":"https:\/\/tco.am\/blog\/wp-json\/wp\/v2\/posts\/307"}],"collection":[{"href":"https:\/\/tco.am\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tco.am\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tco.am\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tco.am\/blog\/wp-json\/wp\/v2\/comments?post=307"}],"version-history":[{"count":12,"href":"https:\/\/tco.am\/blog\/wp-json\/wp\/v2\/posts\/307\/revisions"}],"predecessor-version":[{"id":342,"href":"https:\/\/tco.am\/blog\/wp-json\/wp\/v2\/posts\/307\/revisions\/342"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/tco.am\/blog\/wp-json\/wp\/v2\/media\/325"}],"wp:attachment":[{"href":"https:\/\/tco.am\/blog\/wp-json\/wp\/v2\/media?parent=307"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tco.am\/blog\/wp-json\/wp\/v2\/categories?post=307"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tco.am\/blog\/wp-json\/wp\/v2\/tags?post=307"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}