GitHub

1. Create a GitHub account.

Go to https://github.com/. In the upper right corner, pick a user name, type your email address, create a password, and press the green button that says “Sign up for free”. Your instructor’s username is MarkMeretzky and his GitHub account is here.

After you have logged into your new account, you can chicken out and delete it if you want to make a fresh start. Press the Account Settings button (a wrench and screwdriver) in the upper right. Then select Account Settings in the menu on the left. Then press the red “Delete your account” button.

2. Set up git.

Now that you have logged into GitHub, you will see the GitHub Bootcamp, containing four big, square buttons (If you don’t see them, click on Documentation → GitHub Help in the lower right.) Press the first button, “Set Up Git”. Follow the directions for installing the program git.

iPhone people in INFO1-CE9236 must install the program git on a Mac. Android people in INFO1-CE9705 and C++ people in INFO1-CE9264, INFO1-CE9265, and INFO1-CE9266 can install the program git on any machine: Mac, PC, Linux or other Unix. You might already have git on your machine.

git on Macintosh

In the instructions for setting up git and generating ssh keys, type the white commands (e.g., ls), not the green lines (e.g., config id_rsa id_rsa.pub known_hosts) in the Terminal window. The green lines are the lines that the computer types back to you. Do not type the dollar sign at the start of the while lines. That dollar sign is the Bash shell prompt. For example, to see if you have a subdirectory named .ssh in your home directory, you could say the following. (ls stands for “list”; the l is a lowercase L, not the digit 1. The ~ is a tilde and stands for your home directory.)

ls -ld ~/.ssh
And to see the files in this directory, you could say
ls -l ~/.ssh

iPhone people in INFO1-CE9236 can now skip down to section 6 below.

git on Microsoft Widows

I downloaded and ran Git-1.7.6-preview20110708.exe and followed the instructions.
Select Destination Location: C\Program Files (x86)\Git:
Select Components: I just pressed Next.
Select Start Menu Folder: Git
Adjusting your PATH Environment: • Use Git Bash Only
Choosing the SSH executable: • Use OpenSSH
Configuring the line ending conversions: • Checkout Windows-style

If it says that it could not create the directory C:\Program Files (x86)\Git because access is denied, select the destination location C:\Users\Myname\AppData\Local\Git instead.
To launch Git Bash,
Microsoft Windows start button → All Programs → Git folder → Git Bash

git on i5.nyu.edu

For those of you who use the Solaris Unix server i5.nyu.edu, git has already been installed on this machine:

/usr/local/bin/git --version
git version 1.7.5.4
/usr/local/bin/git --help
more /usr/local/doc/git/Documentation/git.txt

git on Linux

I installed git on my Red Hat Linux box oit.scps.nyu.edu by downloading the source code of git onto oit.scps.nyu.edu by going to http://git-scm.com/ and clicking on Source in the “Download Git” box on the right. Then I compiled the source code with the folloowing commands.

wget http://kernel.org/pub/software/scm/git/git-1.7.5.4.tar.bz2
bunzip2 git-1.7.5.4.tar.bz2
tar xvf git-1.7.5.4.tar
rm git-1.7.5.4.tar
cd git-1.7.5.4
more README
more INSTALL
make
make install

The executable file of git installed into the directory ~/bin.

3. Create a repository.

A repository (abbreviated repo) will hold the files you upload to GitHub. Press the second big, square button, “Create A Repository” and follow the directions. The “Project Name” of your first repository will be Feb13, with an uppercase letter O and no space.

Who has access to this repository? Press the radio button for Anyone. Then go to the instructions for iPhone people below.

When you are done creating the repository, you can see all of your repositories by clicking Account Settings (the wrench and screwdriver) in the upper right, and then Repositories in the menu on the left.

Want to chicken out and delete your new repository so you can make a fresh start? Click on the repository and then press
Settings → Danger Zone → Delete this repository.

iPhone people: skip down to section 6 below.

4. Android people:
upload your project into the repository

When Eclipse starts up, it asks you to select a workspace directory. Instead of accepting the default directory named workspace, ask it for a directory named INFO1-CE9705.
On Mac, for example,
Select a workspace: /Users/myname/Documents/INFO1-CE9705     (instead of /Users/myname/Documents/workspace)
On a PC in 7 E 12 lab 227,
Select a workspace: C:\Users\computerlab\INFO1-CE9705     (instead of C:\Users\computerlab\workspace)

Create your project using Eclipse. Then type the following in the Terminal window of your Mac, or the Command Prompt window of your PC. username is your GitHub loginname.

git config --global user.name "Your Real Name"
git config --global user.email "youremailaddress"

cd to your INFO1-CE9705 directory
git init
ls -ld .git

git add Projectname
git commit -m 'I committed Projectname.'
git remote add origin git@github.com:username/INFO1-CE9705.git
git pull origin master
git push -u origin master

Then point your browser at your INFO1-CE9705 repository at GitHub. Click on the folder for the project that you just uploaded. There’s a Download ZIP button you can press to download the entire project as a .zip file. You can then import the .zip file into Eclipse; see these instructions.

5. C++ People:
upload your .C file into the repository.

C++ people will upload the .C or .cpp file they created (e.g., hello.C). In the following instructions, we will assume that the name of the file to be uploaded is filename. We will assume that the name of the repository is repositoryname (e.g., INFO1-CE9264). We will assume that your GitHub username is username.

To upload the file filename to the repository repositoryname, type the following commands in your Macintosh Terminal window, or your Git Bash window in Microsoft Windows, or your Unix shell window. We assume you have already uploaded a README file, above. The git remote add origin might be unnecessary if you have previously given this command; git will say “remote origin already exists’.

git config --global user.name "Your Real Name"
git config --global user.email "youremailaddress"
ls -l ~/.gitconfig
git config --list

cd to the directory that contains filename
git help

git init
ls -ld .git
git status

git add filename
git ls-files

git commit -m 'I added filename to the repository named repositoryname.'

git remote add origin git@github.com:username/repositoryname.git
git remote --verbose

git push origin master

Then view the repository, select filename, and click on raw.

Microsoft Windows people: to see the manual page for each command, point your browser at C:\Users\Yourname\AppData\Git\doc\git\html\git-init.html, git-add.html, etc. More documentation at GitImmersion.

6. iPhone people:
upload your Xcode project into the repository.

When you created your project in Xcode, you did not check the checkbox for “Source Control: Create local git repository for this project”. You should therefore have no .git directory, and we will remove the .git directory if it does exist. Then we will give the git init command below to create the .git directory.

Let’s assume your project is named Feb13 and is stored in a folder named Feb13 on your Macintosh Desktop. username is your GitHub username.

  1. Launch the Macintosh Terminal app.
    cd ~/Desktop/Feb13
    pwd                     (verify that you have travelled to the Feb13 directory)
    
    git config --global user.name "Your Real Name"        (e.g., "John Smith")
    git config --global user.email "youremailaddress"     (e.g., "john.smith@smithco.com")
    git config --list       (verify that you created user.name and user.email)
    
    ls -ld .git             (verify that the .git folder does not yet exist)
    rm -fR .git         (type this command, if necessary, to remove the .git folder)
    ls -ld .git             (verify that the .git folder does not now exist)
    
    git init
    Initialized empty Git repository in /Users/nyuuser/Desktop/Feb13/.git/
    ls -ld .git             (verify that the .git folder now does exist)
    
    touch README            (create an empty README file)
    ls -l README            (verify that you created a README file)
    
    git add .               (the dot stands for the current directory)
    git ls-files            (verify that you added the files to git's index)
    
    git commit -m 'first commit'
    
    git remote add origin git@github.com:username/Feb13.git
    git remote -v           (verify that you added a remote named origin)
    origin	git@github.com:username/Feb13.git (fetch)
    origin	git@github.com:username/Feb13.git (push)
    
    git push -u origin master
    

  2. Point your browser at https://github.com/username/Feb13/ to see your Feb13 repository. Here’s my Feb14 repository; look in the Feb14 folder to see the file main.m. If necessary, have the browser reload the page. Press Download ZIP to download the repository as a .zip file.

7. Change your mind

If you change your mind, you can remove the file from GitHub:

git rm filename
git commit -m 'I removed filename from repository repositoryname.'
git remote add origin git@github.com:username/repositoryname.git
git push origin master