git_introduction
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| git_introduction [2018/11/05 23:00] – [Git basics, Steve's version] tell | git_introduction [2018/11/16 16:47] (current) – ilena | ||
|---|---|---|---|
| Line 5: | Line 5: | ||
| Github is an online service that provides two main things (an lots of others): git repositories "in the cloud", | Github is an online service that provides two main things (an lots of others): git repositories "in the cloud", | ||
| - | Before doing anything, sign up with github (create a username and password, and join the Eastbots organization: | + | Before doing anything, sign up with github (create a username and password, and find the Eastbots organization: |
| - | (does someone | + | |
| + | Once you have a github account, Amr, Steve, or Ilena can add you to the Eastbots organization in github. | ||
| ====== Installing Git ====== | ====== Installing Git ====== | ||
| 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:// | + | We found a good windows download here https:// |
| ====== Git basics, Steve' | ====== Git basics, Steve' | ||
| + | Here's a drawing that might help understand the basics: | ||
| + | {{ : | ||
| + | |||
| + | And here's another: https:// | ||
| ===== git clone ===== | ===== git clone ===== | ||
| Clone is used to copy an existing repository - typically to get your own local repository from the " | Clone is used to copy an existing repository - typically to get your own local repository from the " | ||
| Line 20: | Line 25: | ||
| to put a copy of the pcboards-2018 tree onto your own computer. | to put a copy of the pcboards-2018 tree onto your own computer. | ||
| - | * git pull | + | Here's a screenshot showing the complete process. |
| - | * git status | + | {{ :: |
| - | * git add | + | |
| - | * git commit | + | ===== git pull ===== |
| - | * git push | + | The pull command updates your local repository and working copy with new changed made and pushed to the parent repository on github. |
| + | |||
| + | Unless you only did your clone seconds ago, someone else on the team may have submitted changes since you cloned. | ||
| + | |||
| + | ===== aside: your first edit ===== | ||
| + | |||
| + | Exercise: | ||
| + | * Clone the Team-4795/ | ||
| + | * find the file gitplay/ | ||
| + | * 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 " | ||
| + | |||
| + | {{ : | ||
| + | |||
| + | Some editors will run right in the terminal, others will start up a new window in which they can support | ||
| + | menus and mouse actions. | ||
| + | |||
| + | {{ : | ||
| + | |||
| + | ===== git status | ||
| + | Git status shows what you've done in your working copy, listing files that have been changed or created. | ||
| + | {{ : | ||
| + | In white is my prompt, where I typed the '' | ||
| + | |||
| + | 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 add ===== | ||
| + | When you've made a worthwhile change (say adding a new function or component), use "'' | ||
| + | |||
| + | 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 | ||
| + | Commit makes permanent all of the changes that you have staged with the git add command. | ||
| + | for you to type in a commit message describing what you changed. | ||
| + | Good commit messages help your teammates (and you) understand why the program or design was changed. | ||
| + | {{ : | ||
| + | |||
| + | On linux, the text editor that git starts for the commit message can be changed with the $EDITOR environment variable. | ||
| + | |||
| + | To make a simple commit without using a text editor, you can put the message on the command line with the '' | ||
| + | git commit -m "added my two cents" | ||
| + | |||
| + | ===== git push ===== | ||
| + | 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 "'' | ||
| + | |||
| + | 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. | ||
| + | |||
| + | {{ : | ||
| + | |||
| + | |||
| + | Exercise: | ||
| + | * Run '' | ||
| + | * Look at https:// | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | ====== Daily Use of Git ====== | ||
| + | |||
| + | Before you start working for the day or session, do "git pull" to download everyone else's changes. | ||
| + | |||
| + | As you pause for the end of the day, or finish somthing big, do "git commit" | ||
| + | so that everyone else can see your work. | ||
| ====== References ====== | ====== References ====== | ||
| + | * https:// | ||
| * official git documentation and tutorial: https:// | * official git documentation and tutorial: https:// | ||
| * another tutorial https:// | * another tutorial https:// | ||
git_introduction.1541476800.txt.gz · Last modified: 2018/11/05 23:00 by tell
