{"id":103,"date":"2018-09-02T05:27:02","date_gmt":"2018-09-02T05:27:02","guid":{"rendered":"https:\/\/www.courses.tegabrain.com\/cc18\/?page_id=103"},"modified":"2018-09-02T05:27:02","modified_gmt":"2018-09-02T05:27:02","slug":"github-and-command-line","status":"publish","type":"page","link":"https:\/\/www.courses.tegabrain.com\/cc18\/github-and-command-line\/","title":{"rendered":"Github and Command line"},"content":{"rendered":"<ul>\n<li>Read about<a href=\"http:\/\/git-scm.com\/book\/en\/v2\/Getting-Started-About-Version-Control\"> version control<\/a> and read through <a href=\"https:\/\/sklise.com\/2012\/09\/22\/introduction-to-git\/\">this excellent introduction to git <\/a><\/li>\n<li>As outlined in the tutorial you should have signed up for a Github account here: <a href=\"https:\/\/github.com\/\">https:\/\/github.com\/ <\/a><\/li>\n<li>Download the Github client so you have it &#8211; <a href=\"https:\/\/desktop.github.com\/\">Github client<\/a>. You can use the Github client instead of the command line.<\/li>\n<\/ul>\n<h2>Basic setup<\/h2>\n<p>Although this is install and setup is covered in the introduction to git (linked above), here are the key steps again:<\/p>\n<h2>Install:<\/h2>\n<ul>\n<li>Mac OSX: You can also install Git via the download from the <a href=\"http:\/\/git-scm.com\/download\">git website<\/a> or through package management tools such as Homebrew and Macports.<\/li>\n<li><a href=\"https:\/\/support.codebasehq.com\/articles\/getting-started\/git-on-windows\">Windows: Install Git for Windows<\/a> which includes a Unix-like Bash terminal environment that matches the commands. Follow the instructions.\n<ul>\n<li>use all the default settings.<\/li>\n<li>When you get to the <code>Adjusting your PATH environment<\/code> screen, be sure to choose the option for <code>Use Git Bash Only<\/code>.<\/li>\n<li>You should have now have a program in your Start Menu called Git Bash. If you hit the Windows key to pull up the start menu and type \u201cgit bash\u201d you should see the program highlighted.<\/li>\n<li>If you&#8217;re familiar with the Win\/DOS Command shell but are new to Bash, check out this <a href=\"http:\/\/www.yolinux.com\/TUTORIALS\/unix_for_dos_users.html\">DOS &#8211; Bash command comparison.<\/a><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ul>\n<li>Linux: Install git through your distro&#8217;s package management system<\/li>\n<\/ul>\n<h2>Configure Git in the Command Line<\/h2>\n<ul>\n<li>Set you username and email address (only need to do this once).<br \/>\n<code>$ git config --global user.name \"YOUR_FULL_NAME\"<\/code><br \/>\n<code>$ git config --global user.email \"YOUR_EMAIL_ADDRESS<\/code>`<\/li>\n<li> Turn on git colors with makes reading status and diffs much easier (only need to do this once). You shouldn&#8217;t need to do this if you&#8217;re using the Git Bash installed by Git for Windows.<br \/>\n<code>$ git config --global color.ui true<\/code><\/li>\n<\/ul>\n<h2>Want to push your homework to your github account?<\/h2>\n<p>There are 3 steps:<\/p>\n<p>1) <code>git add<\/code> &#8211; stage a file for commit, use <code>git add path-of-your-new-file-or-directory<\/code> or <code>git add .<\/code>which will add all modified files (careful with this one!), also responds to wildcards (like *.txt adds all .txt files)<\/p>\n<p>2) <code>git commit -m \"your comment here\"<\/code> &#8211; commits changes for upload with a comment. If you forget to add the comment, you will get stuck in a weird text editor program called VIM. It&#8217;s a pain. Press esc and then :wq to exit.<\/p>\n<p>3)<code>git push origin 'your branch name' <\/code>&#8211; pushes your work to your external repository online (we&#8217;re using github), note the branch name is usually<code>master<\/code>.<\/p>\n<p>If you get some errors saying commit not made due to the upstream being ahead of your repository, pull the changes from the remote first. <code>git pull<\/code> Then try these three steps again.<\/p>\n<h3>Command line basics<\/h3>\n<p><code>ls<\/code> &#8211; list file in directory<br \/>\n<code>pwd<\/code> &#8211; shows the path of your current location<br \/>\n<code>cd<\/code> &#8211; change directory, follow with the name of a folder in your current location or a path<br \/>\n<code>cd ..<\/code> &#8211; follow with .. to go up a directory<br \/>\n<code>mkdir<\/code> &#8211; make a new dir<br \/>\n<code>touch<\/code> &#8211; create an empty file or update the timestamp on an existing file<br \/>\n<code>rm<\/code> &#8211; follow with a file name to delete file<br \/>\n<code>cp<\/code> &#8211; follow with a file name to copy file<br \/>\n<code>mv<\/code> &#8211; follow with a file name and then a location to move file to new location<br \/>\nAnd for some fun:<br \/>\n<code>say<\/code> &#8211; gets your computer talking, follow with a phrase or word<\/p>\n<p>Be careful, from the command line you can do many more things than from a finder or GUI. It is possible to delete and move system files in ways that can break your OS. Make sure you think about what you are doing and ask me in class or via the code forum if you are worried about something you are trying to do.<\/p>\n<h3>Git command line basics<\/h3>\n<p><code>git init<\/code> &#8211; initialize git in your local directory<br \/>\n<code>git status<\/code> &#8211; gives the status of your repo<\/p>\n<p>To upload, there are 3 steps:<\/p>\n<p><code>git add<\/code> &#8211; stage a file for commit, responds to wildcards like *.txt (adds all .txt file) and . which refers to all modified files (careful with this one!)<br \/>\n<code>git commit -m \"your comment here\"``` - commits changes for upload with a comment<br \/>\n<code>git push origin 'your branch name'``` - pushes your work to your external repository online (we're using github), note the branch name is for us is gh-pages.<\/code><\/code><\/p>\n<h3>If you have made changes online and want to download them to your local repo:<\/h3>\n<p><code>git pull<\/code> &#8211; pull in any changes from the remote<\/p>\n<h3>Other commands:<\/h3>\n<p><code>git checkout<\/code> &#8211; switch to a branch, commit, or tag; the base location is the master branch<br \/>\n<code>git rm<\/code> &#8211; remove a file or folder form the staging area, removing a modfied file may require the -f argument to force it, -r adds files recursively (useful within folders).<br \/>\n<code>git mv<\/code> &#8211; move or rename files or folders, only works for files currently managed by git (aka added previously)<br \/>\n<code>git branch some_branch<\/code> &#8211; creates a branch called &#8220;some_branch&#8221;; don;t forget to switch to it using git checkout!<br \/>\n<code>git merge some_branch<\/code> &#8211; merge a branch into the current branch, in this case merge &#8220;some_branch&#8221; with &#8220;master&#8221;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Read about version control and read through this excellent introduction to git As outlined in the tutorial you should have signed up for a Github account here: https:\/\/github.com\/ Download the Github client so you have it &#8211; Github client. You can use the Github client instead of the command line. Basic setup Although this is<a class=\"more-link button\" href=\"https:\/\/www.courses.tegabrain.com\/cc18\/github-and-command-line\/\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-103","page","type-page","status-publish","hentry"],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/Paeb9f-1F","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/www.courses.tegabrain.com\/cc18\/wp-json\/wp\/v2\/pages\/103","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.courses.tegabrain.com\/cc18\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.courses.tegabrain.com\/cc18\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.courses.tegabrain.com\/cc18\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.courses.tegabrain.com\/cc18\/wp-json\/wp\/v2\/comments?post=103"}],"version-history":[{"count":1,"href":"https:\/\/www.courses.tegabrain.com\/cc18\/wp-json\/wp\/v2\/pages\/103\/revisions"}],"predecessor-version":[{"id":104,"href":"https:\/\/www.courses.tegabrain.com\/cc18\/wp-json\/wp\/v2\/pages\/103\/revisions\/104"}],"wp:attachment":[{"href":"https:\/\/www.courses.tegabrain.com\/cc18\/wp-json\/wp\/v2\/media?parent=103"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}