{"id":1104,"date":"2017-12-19T13:40:16","date_gmt":"2017-12-19T18:40:16","guid":{"rendered":"http:\/\/bluegalaxy.info\/codewalk\/?p=1104"},"modified":"2018-01-05T09:41:46","modified_gmt":"2018-01-05T14:41:46","slug":"how-to-use-git-and-github","status":"publish","type":"post","link":"https:\/\/bluegalaxy.info\/codewalk\/2017\/12\/19\/how-to-use-git-and-github\/","title":{"rendered":"How to use Git and Github"},"content":{"rendered":"<h4><strong>What is Git?<\/strong><\/h4>\n<p>According to the GIT software website:<br \/>\n<a href=\"https:\/\/git-scm.com\/\">https:\/\/git-scm.com\/<\/a><\/p>\n<blockquote><p>Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.<\/p>\n<p>Git is easy to learn and has a tiny footprint with lightning fast performance. It outclasses SCM tools like Subversion, CVS, Perforce, and ClearCase with features like cheap local branching, convenient staging areas, and multiple workflows.<\/p><\/blockquote>\n<p>Git is a software tool that once installed on your machine, takes in commands at the command line, allowing you to quickly and easily manage versioning of files in a project. Git allows branching, forking, and Diff analysis between versions of code. Here is a glossary of common lingo used with Git:<\/p>\n<p><strong>Project<\/strong>: Repository or &#8220;repo&#8221;.<\/p>\n<p><strong>Working directory<\/strong>: The location on your computer where your project lives.<\/p>\n<p><strong>Staging:<\/strong> Preparing or getting ready. Move the selected modified files into staging area before committing.<\/p>\n<p><strong>Commit<\/strong>: Git\u2019s way of \u201csaving\u201d.<\/p>\n<p><strong>Command line<\/strong>: A place where we can type commands.<\/p>\n<p><strong>push<\/strong>: Push changes from local Git to GitHub.<\/p>\n<p><strong>pull<\/strong>: Get changes from Github down to local computer.<\/p>\n<p><strong>clone<\/strong>: Copy an existing repository from a server to our computer\u2019s hard drive.<\/p>\n<p><strong>branch<\/strong>: A parallel version of a repository.<\/p>\n<p><strong>master<\/strong>: The primary branch.<\/p>\n<p><strong>fork<\/strong>: A personal copy of another user&#8217;s repository.<\/p>\n<p>For a more comprehensive Git glossary, see:<br \/>\n<a href=\"https:\/\/help.github.com\/articles\/github-glossary\/\">https:\/\/help.github.com\/articles\/github-glossary\/<\/a><\/p>\n<p>&nbsp;<\/p>\n<h4><strong>Common Command Pattern<br \/>\n<\/strong><\/h4>\n<p>When working on a project, the most common commands that are used after saving an edit to a project file, (listed in order of pattern usage) are <strong>init<\/strong>, <strong>status<\/strong>, <strong>add<\/strong>, <strong>commit<\/strong>, and <strong>push<\/strong>. These commands are run one at a time, hitting enter after each:<\/p>\n<p>Init:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">git init<\/pre>\n<p>then status:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">git status<\/pre>\n<p>then add:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">git add .<\/pre>\n<p>then commit, with a message that states what was changed:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"raw\">git commit -m \u201cAdded a header to the main page.\u201d<\/pre>\n<p>Then, if you are using github, push the changes up to the github repo:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"raw\">git push<\/pre>\n<p>&nbsp;<\/p>\n<h4><strong>What is Github?<\/strong><\/h4>\n<p>According to the Github website:<br \/>\n<a href=\"https:\/\/github.com\/\">https:\/\/github.com\/<\/a><\/p>\n<blockquote><p>GitHub is a code hosting platform for version control and collaboration. It lets you and others work together on projects from anywhere.<\/p><\/blockquote>\n<p>Note: When publishing to github, your code is available for anyone to see or fork against, so if you want to keep your code private or your code is commercial, then do not publish to github.<\/p>\n<p>To get started with github, go to github.com and sign up. After that, you can create a new repository by clicking the + symbol. For example:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" id=\"img_ds\" class=\"alignnone size-full wp-image-1113\" src=\"http:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2017\/12\/new_repository.jpg\" alt=\"\" width=\"231\" height=\"173\" \/><\/p>\n<p>Then give your repository a name. For example:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" id=\"img_ds\" class=\"alignnone wp-image-1114 size-full\" src=\"http:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2017\/12\/repository_name.png\" alt=\"\" width=\"511\" height=\"186\" srcset=\"https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2017\/12\/repository_name.png 511w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2017\/12\/repository_name-300x109.png 300w\" sizes=\"auto, (max-width: 511px) 100vw, 511px\" \/><\/p>\n<p>Finally, set this new repository as an origin by running the command:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">git remote add origin https:\/\/github.com\/chris-relaxing\/parse_jupyter.git<\/pre>\n<p>then:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">git push -u origin master<\/pre>\n<p>Once a project is pushed to this repo using <code class=\"EnlighterJSRAW\" data-enlighter-language=\"no-highlight\">git push<\/code> for example:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" id=\"img_ds\" class=\"alignnone wp-image-1121 size-full\" src=\"http:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2017\/12\/git_push.jpg\" alt=\"\" width=\"570\" height=\"174\" srcset=\"https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2017\/12\/git_push.jpg 570w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2017\/12\/git_push-300x92.jpg 300w\" sizes=\"auto, (max-width: 570px) 100vw, 570px\" \/><\/p>\n<p>then check github to confirm that the update was pushed:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" id=\"img_ds\" class=\"alignnone wp-image-1123 size-full\" src=\"http:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2017\/12\/git_push_confirm.png\" alt=\"\" width=\"692\" height=\"227\" srcset=\"https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2017\/12\/git_push_confirm.png 692w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2017\/12\/git_push_confirm-300x98.png 300w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2017\/12\/git_push_confirm-676x222.png 676w\" sizes=\"auto, (max-width: 692px) 100vw, 692px\" \/><\/p>\n<p>For more information about using git and github, see:<br \/>\n<a href=\"https:\/\/git-scm.com\/doc\">https:\/\/git-scm.com\/doc<\/a><br \/>\n<a href=\"https:\/\/guides.github.com\/activities\/hello-world\/\">https:\/\/guides.github.com\/activities\/hello-world\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is Git? According to the GIT software website: https:\/\/git-scm.com\/ Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. Git is easy to learn and has a tiny footprint with lightning fast performance. It outclasses SCM tools like Subversion, &hellip; <a href=\"https:\/\/bluegalaxy.info\/codewalk\/2017\/12\/19\/how-to-use-git-and-github\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">How to use Git and Github<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[78],"tags":[79],"class_list":["post-1104","post","type-post","status-publish","format-standard","hentry","category-technologies-and-tools","tag-git"],"_links":{"self":[{"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/posts\/1104","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/comments?post=1104"}],"version-history":[{"count":25,"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/posts\/1104\/revisions"}],"predecessor-version":[{"id":1292,"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/posts\/1104\/revisions\/1292"}],"wp:attachment":[{"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/media?parent=1104"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/categories?post=1104"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/tags?post=1104"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}