User Tools

Site Tools


git_introduction

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
git_introduction [2018/11/14 23:43] tellgit_introduction [2018/11/16 16:47] (current) ilena
Line 6: Line 6:
  
 Before doing anything, sign up with github (create a username and password, and find the Eastbots organization: https://github.com/Team-4795. Before doing anything, sign up with github (create a username and password, and find the Eastbots organization: https://github.com/Team-4795.
 +
 Once you have a github account, Amr, Steve, or Ilena can add you to the Eastbots organization in github. Once you have a github account, Amr, Steve, or Ilena can add you to the Eastbots organization in github.
  
Line 11: Line 12:
  
 If you're using linux, git should be available easily with the software package manager in your linux system. If you're using linux, git should be available easily with the software package manager in your linux system.
-We found a good windows download here https://git-scm.com/download/win  (Ilena, is this the one we put on yoru computer?)+We found a good windows download here https://git-scm.com/download/win  
  
 ====== Git basics, Steve's version ====== ====== Git basics, Steve's version ======
Line 23: Line 24:
     git clone https://github.com/Team-4795/pcboards-2018.git     git clone https://github.com/Team-4795/pcboards-2018.git
 to put a copy of the pcboards-2018 tree onto your own computer.   Get the link to the existing repository from the green "clone or download" button in the repository's github page.  to put a copy of the pcboards-2018 tree onto your own computer.   Get the link to the existing repository from the green "clone or download" button in the repository's github page. 
 +
 +Here's a screenshot showing the complete process.  We change into a folder (directory) that already exists called Eastbots, and run "ls" only to find that it is an empty folder.  Then we do the clone, and ls again.  We see that a new directory called pcboards-2018 has been created.
 +{{ ::git-clone-pcboards.png?400 |}}
  
 ===== git pull ===== ===== git pull =====
 The pull command updates your local repository and working copy with new changed made and pushed to the parent repository on github.  Simply type "''git pull''" The pull command updates your local repository and working copy with new changed made and pushed to the parent repository on github.  Simply type "''git pull''"
 +
 +Unless you only did your clone seconds ago, someone else on the team may have submitted changes since you cloned.  Run ''git pull'' early and often to stay up to date!
 +
 +===== aside: your first edit =====
 +
 +Exercise:
 +  * Clone the Team-4795/pcboards-2018 repository  (see git clone above)
 +  * find the file gitplay/team-git-practice-file that was copied to your computer
 +  * Using a text editor (like textedit, notepad, emacs, or vim), add one new line to the file that contains at least your name.  Do not use word or any other word processor to edit these plain-text files.
 +
 +These screenshots show what you'll see.  Use "cd" to change into the pcboards-2018 directory, and ls to list the files there.  Then cd into the gitplay directory (folder).  Running ls there shows that there's a file called team-git-practice-file there.  This is the file we want, so we run our text editor on that file.
 +
 +{{ :git-cd-editfile.png?400 |}}
 +
 +Some editors will run right in the terminal, others will start up a new window in which they can support
 +menus and mouse actions.  That can look like this:
 +
 +{{ :git-editfile-emacs.png?300 |}}
  
 ===== git status ===== ===== git status =====
 Git status shows what you've done in your working copy, listing files that have been changed or created. Git status shows what you've done in your working copy, listing files that have been changed or created.
-(TODO screenshot of git status output)+{{ :git-status.png?400 |}} 
 +In white is my prompt, where I typed the ''git status'' command and pressed return.  The important part of the output is in the middle, under "Changes not staged for commit" Here one file has been modified, and its name is shown in red. 
 + 
 +Exercise: 
 +  * do the edit shown above, either from the command line or from a graphical file manager 
 +  * open a terminal and find the team-git-practice-file again 
 +  * run "''git status''" as shown above. 
  
 ===== git add ===== ===== git add =====
 When you've made a worthwhile change (say adding a new function or component), use "''git add'' //filename//" to "stage" the change in preparation for committing it permanently to the repository. When you've made a worthwhile change (say adding a new function or component), use "''git add'' //filename//" to "stage" the change in preparation for committing it permanently to the repository.
 +
 +Exercise:
 +  * find team-git-practice-file again; the file that you changed above
 +  * stage your change by running:
 +
 +    git add team-git-practice-file
 +
  
 ===== git commit ===== ===== git commit =====
Line 38: Line 74:
 for you to type in a commit message describing what you changed.  The first line of the message should be a brief summary.  Then leave a blank line, and possibly describe the reasons for the changes in more detail. for you to type in a commit message describing what you changed.  The first line of the message should be a brief summary.  Then leave a blank line, and possibly describe the reasons for the changes in more detail.
 Good commit messages help your teammates (and you) understand why the program or design was changed. Good commit messages help your teammates (and you) understand why the program or design was changed.
- +{{ :git-commit-editor.png?400 |}}
-(screenshot of editor plus commit message)+
  
 On linux, the text editor that git starts for the commit message can be changed with the $EDITOR environment variable.  (how does this work on windows?) On linux, the text editor that git starts for the commit message can be changed with the $EDITOR environment variable.  (how does this work on windows?)
Line 49: Line 84:
 The last step in doing a useful addition to a project is to push it up to github so the world (and your teammates) can see it.  Type "''git push''" You'll have to type in your github password every time. The last step in doing a useful addition to a project is to push it up to github so the world (and your teammates) can see it.  Type "''git push''" You'll have to type in your github password every time.
  
-The only way I know to avoid typing in your github password with every commit is to do your initial clone using ssh, and also create and upload your ssh public key to github.  But ssh doesn't work inside the firewall at ECHHS, so best to learn your github password. +The only way I know to avoid typing in your github password with every commit is to do your initial clone using ssh, and also create and upload your ssh public key to github.  But ssh doesn't work inside the firewall at ECHHS, so best to learn your github password.  Here's what git push can look like:
  
 +{{ :git-push-nopw.png?400 |}}
  
  
 +Exercise:
 +  * Run ''git push'' to send your change up to github
 +  * Look at https://github.com/Team-4795/pcboards-2018/tree/master/gitplay to see your change and its message
  
  
Line 66: Line 104:
  
 ====== References ====== ====== References ======
 +  * https://www.youtube.com/watch?v=boeCjJKg-LY&t=0s&list=PLUSdSy9CkwBIiISFMa_ThWmtFCKtYLUE_&index=6 - Eastbots programming video focusing on git 
   * official git documentation and tutorial: https://git-scm.com/book/en/v2/Getting-Started-Git-Basics   * official git documentation and tutorial: https://git-scm.com/book/en/v2/Getting-Started-Git-Basics
   * another tutorial https://product.hubspot.com/blog/git-and-github-tutorial-for-beginners   * another tutorial https://product.hubspot.com/blog/git-and-github-tutorial-for-beginners
  
git_introduction.1542256994.txt.gz · Last modified: 2018/11/14 23:43 by tell