{"id":402,"date":"2017-08-19T06:36:25","date_gmt":"2017-08-19T06:36:25","guid":{"rendered":"http:\/\/mansainfotech.com\/blog\/?p=402"},"modified":"2017-08-19T06:36:25","modified_gmt":"2017-08-19T06:36:25","slug":"git-and-github-a-quick-look","status":"publish","type":"post","link":"https:\/\/mansainfotech.com\/blog\/git-and-github-a-quick-look\/","title":{"rendered":"Git and GitHub &#8211; A Quick Look"},"content":{"rendered":"<p class=\"western\" align=\"justify\"><span style=\"font-family: verdana,sans-serif; color: #c95f66;\"><span style=\"font-size: medium;\">Is Git just another word for GitHub, are they related or are they completely different? &#8211; This post is specifically built to answers such trivial questions faced by most folks.<\/span><\/span><\/p>\n<p class=\"western\" align=\"justify\"><span style=\"font-family: verdana,sans-serif; color: #c95f66;\"><span style=\"font-size: medium;\">So, Let\u2019s get cracking&#8230;<\/span><\/span><\/p>\n<p class=\"western\" align=\"justify\"><span style=\"font-family: verdana,sans-serif;\"><span style=\"color: #000000;\"><span style=\"font-size: medium;\">What is <\/span><\/span><span style=\"color: #000000;\"><span style=\"font-size: medium;\"><span style=\"text-decoration: underline;\">Git<\/span><\/span><\/span><span style=\"color: #000000;\"><span style=\"font-size: medium;\">? <\/span><\/span><\/span><\/p>\n<p class=\"western\" align=\"justify\"><span style=\"font-family: verdana,sans-serif;\"><span style=\"font-size: medium;\">First thing first, Git is not Github. They are different yet, related to each other. Git is the most popular version control system founded in 2005 by Linus Torvalds. Git installs locally on your computer to handle \u2018version control\u2019. So, to understand git, you should first learn about version control.<\/span><\/span><\/p>\n<p class=\"western\" align=\"justify\"><span style=\"font-family: verdana,sans-serif;\"><span style=\"font-size: medium;\"><i>Version control, in specific terms,<\/i> help you record changes to files or set of files so that you can recall previous versions later. It\u2019s just like \u2013 making small changes, taking snapshot; making small changes and taking another snapshot; so on&#8230;You can then, use Git to step back and forth whenever necessary through each snapshot. <\/span><\/span><\/p>\n<p class=\"western\" align=\"justify\"><span style=\"font-family: verdana,sans-serif;\"><span style=\"font-size: medium;\">And, Git is simply one of many version control systems that you can download and install in your machine. <\/span><\/span><\/p>\n<p class=\"western\" align=\"justify\"><span style=\"font-family: verdana,sans-serif;\"><span style=\"font-size: medium;\"><span style=\"text-decoration: underline;\">Collaboration<\/span>&#8230;If you are working as an individual, then its great. But, what if you want to share your project directory with team \u2013 make changes, send them to your team members or have changes they make appear on your machine\u2019s project directory?<\/span><\/span><\/p>\n<p class=\"western\" align=\"justify\"><span style=\"font-family: verdana,sans-serif;\"><span style=\"font-size: medium;\">For this, Git has a command called <b>Push and Pull, <\/b>which allows to pull in your collaborators changes and push back your own changes. This is good until you and your collaborators are sitting right next to each other. <\/span><\/span><\/p>\n<p class=\"western\" align=\"justify\"><span style=\"font-family: verdana,sans-serif;\"><span style=\"font-size: medium;\">Well, that\u2019s where <span style=\"text-decoration: underline;\">GitHub<\/span> comes! GitHub is a place for storing identical working directories \u2013 also called as repositories or repo. It provides a hub for Git repositories. <\/span><\/span><\/p>\n<p class=\"western\" align=\"justify\"><span style=\"font-family: verdana,sans-serif;\"><span style=\"font-size: medium;\">GitHub is specifically built for Git, yet, they aren\u2019t really linked. You can use any other Git hosting service apart from GitHub. One such alternative is <span style=\"text-decoration: underline;\">Bitbucket<\/span>. (Unlike GitHub) Bitbucket gives private access to repositories.<\/span><\/span><\/p>\n<p class=\"western\" style=\"text-align: center;\" align=\"justify\"><span style=\"font-family: verdana,sans-serif;\"><span style=\"font-size: medium;\">Now, Let\u2019s discuss three main <i>characterstic f<\/i><i>unctions of Git&#8230;<\/i><\/span><\/span><\/p>\n<hr \/>\n<p><span style=\"color: #000000;\"><span style=\"font-family: verdana,sans-serif;\"><span style=\"font-size: medium;\">\u27a8 Creating a local repository of project under <\/span><\/span><\/span><em><span style=\"font-family: verdana,sans-serif;\">project_name<\/span><\/em><strong><span style=\"font-family: verdana,sans-serif;\">\/<\/span><\/strong><span style=\"font-family: verdana,sans-serif;\">.git<\/span><span style=\"color: #000000;\"><span style=\"font-family: verdana,sans-serif;\"><span style=\"font-size: medium;\"> directory in your home directory.<\/span><\/span><\/span><\/p>\n<p><span style=\"color: #000000;\"><span style=\"font-family: verdana,sans-serif;\"><span style=\"font-size: medium;\">\u27a8 Creating directory which allows you to directly see the files. Also, called working area.<\/span><\/span><\/span><\/p>\n<p><span style=\"font-family: verdana,sans-serif; color: #000000;\"><span style=\"font-size: medium;\">\u27a8 Creating staging area where you can store changes to file before any commit. <\/span><\/span><\/p>\n<p>&nbsp;<\/p>\n<p class=\"western\" style=\"text-align: center;\" align=\"left\"><span style=\"font-family: verdana,sans-serif;\"><span style=\"font-size: medium;\"><i>Time to get little deeper into how Git works&#8230;<\/i><\/span><\/span><\/p>\n<hr \/>\n<p><span style=\"font-family: verdana,sans-serif;\"><span style=\"color: #000000;\"><span style=\"font-size: medium;\">\u27a8 Setup,<\/span><\/span><i> <\/i><span style=\"color: #000000;\"><span style=\"font-size: medium;\">i.e. download Git for OSX, Windows or Linux.<\/span><\/span><\/span><\/p>\n<p class=\"western\" align=\"left\"><span style=\"font-family: verdana,sans-serif;\"><span style=\"color: #000000;\"><span style=\"font-size: medium;\">\u27a8 Create a new repository using command: git init<\/span><\/span><\/span><\/p>\n<p class=\"western\" align=\"left\"><span style=\"color: #000000;\"><span style=\"font-family: verdana,sans-serif;\"><span style=\"font-size: medium;\">\u27a8 Create working copy of local repository: <\/span><\/span><\/span><code class=\"western\"><span style=\"color: #000000;\"><span style=\"font-family: verdana,sans-serif;\"><span style=\"font-size: medium;\">git clone \/path\/to\/repository<\/span><\/span><\/span><\/code><\/p>\n<p class=\"western\" align=\"left\"><code class=\"western\"><span style=\"color: #000000;\"><span style=\"font-family: verdana,sans-serif;\"><span style=\"font-size: medium;\">\u27a8 To recall, our local repository consist of three \u2018trees\u2019 maintained by gi<\/span><\/span><\/span><\/code><code class=\"western\"><span style=\"color: #000000;\"><span style=\"font-family: verdana,sans-serif;\"><span style=\"font-size: medium;\">t.<\/span><\/span><\/span><\/code><\/p>\n<p class=\"western\" align=\"left\"><code class=\"western\"><span style=\"color: #000000;\"><span style=\"font-family: verdana,sans-serif;\"><span style=\"font-size: medium;\">\u27a8 Add and commit changes using following commands:<\/span><\/span><\/span><\/code><\/p>\n<blockquote>\n<p class=\"western\" align=\"left\"><code class=\"western\"><span style=\"color: #000000;\"><span style=\"font-family: verdana,sans-serif;\"><span style=\"font-size: medium;\"> git add &lt;filename&gt;<\/span><\/span><\/span><\/code><\/p>\n<p class=\"western\" align=\"left\"><code class=\"western\"><span style=\"color: #000000;\"><span style=\"font-family: verdana,sans-serif;\"><span style=\"font-size: medium;\"> git commit -m \"Commit message\"<\/span><\/span><\/span><\/code><\/p>\n<\/blockquote>\n<p class=\"western\" align=\"left\"><code class=\"western\"><span style=\"color: #000000;\"><span style=\"font-family: verdana,sans-serif;\"><span style=\"font-size: medium;\">\u27a8 To push changes from local to remote repository, use: git push origin master.<\/span><\/span><\/span><\/code><\/p>\n<p class=\"western\" align=\"left\"><code class=\"western\"><span style=\"color: #000000;\"><span style=\"font-family: verdana,sans-serif;\"><span style=\"font-size: medium;\">\u27a8 Branches are used for developing features that isolates from each other. <\/span><\/span><\/span><\/code><\/p>\n<blockquote>\n<p class=\"western\" align=\"left\"><code class=\"western\"><span style=\"color: #000000;\"><span style=\"font-family: verdana,sans-serif;\"><span style=\"font-size: medium;\"> To create new branch:<\/span><\/span><\/span><\/code><\/p>\n<p class=\"western\" align=\"left\"><code class=\"western\"><span style=\"color: #000000;\"><span style=\"font-family: verdana,sans-serif;\"><span style=\"font-size: medium;\"> git checkout -b feature_x<\/span><\/span><\/span><\/code><\/p>\n<p class=\"western\" align=\"left\"><code class=\"western\"><span style=\"color: #000000;\"><span style=\"font-family: verdana,sans-serif;\"><span style=\"font-size: medium;\"> To delete a branch: <\/span><\/span><\/span><\/code><\/p>\n<p class=\"western\" align=\"left\"><code class=\"western\"><span style=\"color: #000000;\"><span style=\"font-family: verdana,sans-serif;\"><span style=\"font-size: medium;\"> git branch -d feature_x<\/span><\/span><\/span><\/code><\/p>\n<p class=\"western\" align=\"left\"><code class=\"western\"><span style=\"color: #000000;\"><span style=\"font-family: verdana,sans-serif;\"><span style=\"font-size: medium;\"> To push branch to remote repository:<\/span><\/span><\/span><\/code><\/p>\n<p class=\"western\" align=\"left\"><code class=\"western\"><span style=\"color: #000000;\"><span style=\"font-family: verdana,sans-serif;\"><span style=\"font-size: medium;\"> git push origin &lt;branch&gt;<\/span><\/span><\/span><\/code><\/p>\n<\/blockquote>\n<p class=\"western\" align=\"left\"><code class=\"western\"><span style=\"color: #000000;\"><span style=\"font-family: verdana,sans-serif;\"><span style=\"font-size: medium;\">\u27a8 To update and merge changes, <\/span><\/span><\/span><\/code><\/p>\n<blockquote>\n<p class=\"western\" align=\"left\"><code class=\"western\"><span style=\"color: #000000;\"><span style=\"font-family: verdana,sans-serif;\"><span style=\"font-size: medium;\"> Update local repository to newest commit and merge remote changes: <\/span><\/span><\/span><\/code><\/p>\n<p class=\"western\" align=\"left\"><code class=\"western\"><span style=\"color: #000000;\"><span style=\"font-family: verdana,sans-serif;\"><span style=\"font-size: medium;\"> git pull<\/span><\/span><\/span><\/code><\/p>\n<p class=\"western\" align=\"left\"><code class=\"western\"><span style=\"color: #000000;\"><span style=\"font-family: verdana,sans-serif;\"><span style=\"font-size: medium;\"> To merge another with your active branch: <\/span><\/span><\/span><\/code><\/p>\n<p class=\"western\" align=\"left\"><code class=\"western\"><span style=\"color: #000000;\"><span style=\"font-family: verdana,sans-serif;\"><span style=\"font-size: medium;\"> git merge &lt;branch&gt;<\/span><\/span><\/span><\/code><\/p>\n<\/blockquote>\n<p class=\"western\" align=\"left\"><code class=\"western\"><span style=\"color: #000000;\"><span style=\"font-family: verdana,sans-serif;\"><span style=\"font-size: medium;\">\u27a8 To study repository history, use: <\/span><\/span><\/span><\/code><\/p>\n<blockquote>\n<p class=\"western\" align=\"left\"><code class=\"western\"><span style=\"color: #000000;\"><span style=\"font-family: verdana,sans-serif;\"><span style=\"font-size: medium;\"> git log<\/span><\/span><\/span><\/code><\/p>\n<\/blockquote>\n<p class=\"western\" align=\"left\"><code class=\"western\"><span style=\"color: #000000;\"><span style=\"font-family: verdana,sans-serif;\"><span style=\"font-size: medium;\">And, there a<\/span><\/span><\/span><\/code><code class=\"western\"><span style=\"color: #000000;\"><span style=\"font-family: verdana,sans-serif;\"><span style=\"font-size: medium;\">re<\/span><\/span><\/span><\/code><code class=\"western\"><span style=\"color: #000000;\"><span style=\"font-family: verdana,sans-serif;\"><span style=\"font-size: medium;\"> lot more <\/span><\/span><\/span><\/code><code class=\"western\"><span style=\"color: #000000;\"><span style=\"font-family: verdana,sans-serif;\"><span style=\"font-size: medium;\">things that<\/span><\/span><\/span><\/code><code class=\"western\"><span style=\"color: #000000;\"><span style=\"font-family: verdana,sans-serif;\"><span style=\"font-size: medium;\"> you can do <\/span><\/span><\/span><\/code><code class=\"western\"><span style=\"color: #000000;\"><span style=\"font-family: verdana,sans-serif;\"><span style=\"font-size: medium;\">with git. <\/span><\/span><\/span><\/code><\/p>\n<p class=\"western\" align=\"justify\"><code class=\"western\"><span style=\"color: #000000;\"><span style=\"font-family: verdana,sans-serif;\"><span style=\"font-size: medium;\"><b>Concluding the topic: <\/b><\/span><\/span><\/span><\/code><code class=\"western\"><span style=\"color: #000000;\"><span style=\"font-family: verdana,sans-serif;\"><span style=\"font-size: medium;\">You must have now got a basic understanding of what Git and GitHub is all about. They are not difficult to grasp, as once you have gotten handle on the basics, you can pick everything up reasonably quickly. <\/span><\/span><\/span><\/code><\/p>\n<p class=\"western\" align=\"justify\"><strong><span style=\"color: #c95f66;\"><code class=\"western\"><span style=\"font-family: verdana,sans-serif;\"><span style=\"font-size: medium;\">Thanks for reading, folks! See you again with my another interesting post. :)<\/span><\/span><\/code><\/span><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Is Git just another word for GitHub, are they related or are they completely different? &#8211; This post is specifically built to answers such trivial questions faced by most folks. So, Let\u2019s get cracking&#8230; What is Git? First thing first, Git is not Github. They are different yet, related to &hellip; <a href=\"https:\/\/mansainfotech.com\/blog\/git-and-github-a-quick-look\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Git and GitHub &#8211; A Quick Look<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":409,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27,33],"tags":[],"class_list":["post-402","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-others","category-web-design-and-development"],"_links":{"self":[{"href":"https:\/\/mansainfotech.com\/blog\/wp-json\/wp\/v2\/posts\/402","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mansainfotech.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mansainfotech.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mansainfotech.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mansainfotech.com\/blog\/wp-json\/wp\/v2\/comments?post=402"}],"version-history":[{"count":0,"href":"https:\/\/mansainfotech.com\/blog\/wp-json\/wp\/v2\/posts\/402\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/mansainfotech.com\/blog\/wp-json\/wp\/v2\/media\/409"}],"wp:attachment":[{"href":"https:\/\/mansainfotech.com\/blog\/wp-json\/wp\/v2\/media?parent=402"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mansainfotech.com\/blog\/wp-json\/wp\/v2\/categories?post=402"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mansainfotech.com\/blog\/wp-json\/wp\/v2\/tags?post=402"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}