A Not-So-Brief Introduction to Github (and Github@IU)

Git basics

Git is a version control system (VCS) that is widly used.
Git In Five Minutes | Everyday GIT With 20 Commands Or So | Practice with git commands

Terminologies

You will act as a developer and submit your work to Github@IU

  1. Go to Github.iu.edu, log in using your user name;
    If it is your first time to use github@IU, you are probably not yet on the organization we created for C343 (C343-Spring2016); ask an AI to add you to the organization before you continue!
  2. Go to the organization (or use the URL https://github.iu.edu/organizations/C343-Spring2016);
  3. Create a repository called C343 followed by your email ID (e.g., C343yye, where yye is Prof. Ye's email ID) on github@IU, in C343-Spring2016 organization. Make sure that you select "Private" and click on "Initialize the repository with a README". Your repositiory needs to sit in the C343-Spring2016 organization;
  4. Check out the HTTPs clone URL of your repository; you will need this address in the following steps;

    Now you need to decide how you want to use git: use the command lines (the "traditional" way) (step 5 below), or use it in Eclipse (step 6 below).
  5. Use git in command lines [basic unix/linux commands]:
    You will use the following command lines on a linux/unix machine, or Mac terminal.
    If you use a Windows machine, use PuTTY to connect to burrow.soic.indiana.edu (a linux machine); you may also try Gitbash (https://git-for-windows.github.io/), and then work with git like you will work in the Mac terminal or a linux machine.
    1. Make a copy of the repository on your local machine:

      git clone https://github.iu.edu/C343-Spring2016/C343yye.git (replacing 'yye' by your IU user name);

      you will be asked to provide your account & password. After you provide the information, you now should have a copy of your repository (named C343...) on the "local" machine.
    2. You are now ready to make changes to your local copy (E.g., you write a code Hello.java under lab1 folder);
      You can use any of the editors (vim, Emacs or pico) to write your code. [vim cheat sheet; Emacs cheat sheet; pico]
    3. Not done yet--you need to upload the changes to github as follows;
      (under your local folder, e.g., ~/C343yye/)
      git add .
      git commit -m "whatever meaningful message"
      git push
      (to remove a file/folder? e.g, git rm -r folder1, followed by git commit & git push)
    4. Now your changes should be propagated to your repository on Github@IU;
  6. Use EGit (git integrated in Eclipse; All git functions can be done through Eclipse).
    The following procedure is based on Eclipse IDE for Java Developers Version: Mars.1 Release (4.5.1)
    1. Clone: Eclipse => File => Import => Git => Projects from Git => URI =>
      Type in URI (https), and user and passwd for authentication =>
      Branch selection (select master) => Location Destination => Import existing projects =>
      Note: If Eclipse complains that there is no project in your repository to import, just click on cancel; and if the Git repository does not show up in the Eclipse window, go to Navigate => Show in => Git Repositories, then you shall see it in the Eclipse window.
    2. Now you have a clone of the repository on your local machine
    3. Try to create a project (HelloWorld) under lab1:
      File => New => Java Project (type in HelloWorld for project name, select lab1 in your repository for location)
    4. Create a class in this project:
      File => New => Class
    5. When you are done with the code, you need to push it upstream:
      The Git Staging view provides a convenient compact overview on all changes you have done compared to the current HEAD revision.
      Open the Git Staging view via the Window -> Show View -> Other... -> Git -> Git Staging menu.
      In this view you select all files which have changed and drag them into the Staged Changes area. To commit the staged changes you write a descriptive commit message and press the Commit button; or you can press the Commit and Push button to commit and push the commit to upstream.
  7. Other options:
    • Use git with GUI: look for "Clone in Desktop" on github.
    • If you really cannot get any of these work, you may create folders/files directly on github. Go to the destination folder in your repository (e.g., week2) and look for the "+" sign to create a new file (and a folder), as shown below.