Git and GitHub

Weekly assignments and final projects will be submitted through GitHub.

Each week, you’ll create a private repository, visible to you and the instructors, with the link provided on Slack. Please do not post assignments to a public repository.

Create and clone your repo

  1. Create your repository on GitHub by clicking on the link provided on Slack.
  2. Under “Clone or download”, make sure you have HTTPS selected and click the copy icon to copy the url.
  3. Open Terminal and cd into the directory where you want to put your assignment. For example,
    $ cd ~/Documents/iOS
  4. Clone your repository. This will create a local copy of the repo on your machine.
    $ git clone <URL>

Create your Xcode project

  1. In Terminal, cd into your repository. Two branches have been created for you: master and development.

  2. Switch to the development branch.
    $ git checkout development
  3. Open Xcode and create a new project inside of your local repository. Leave the checkbox for “Create a Git repository on my Mac” unchecked.

Commit and push changes

As you’re working on the assignment, make sure to add, commit and push your changes to GitHub periodically.

Make sure you’re on the development branch when you’re working on your project. An asterisk next to the branch name indicates the current branch.

$ git branch
* development

If you’re not on development, switch to it.

$ git checkout development
Switched to branch 'development'

Work on your project in Xcode. Once you’re at a good stopping point, switch back to Terminal.

Check the current status of your branch.

$ git status
On branch development
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)


no changes added to commit (use "git add" and/or "git commit -a")

Stage the changes you want to commit. Usually, you will want to stage all of your changes.

$ git add .

If you only need to stage certain changes, you can specify the file name.

$ git add

Commit your changes to your local repository.

$ git commit -m "Update README"

Push your changes to your remote repository on GitHub.

$ git push

Open a pull request

When you’re ready to submit your assignment, open a pull request from the development branch into master.

  1. Go to the Pull requests tab on GitHub. Click on New pull request.
  2. Select base: master and compare: development.
  3. Click Create pull request. Give your pull request a title, such as “Assignment 1”, and click Create pull request again.

If you need to make changes to your assignment after creating the pull request, but before the deadline, you can commit and push changes as usual. GitHub will update your pull request automatically.

Additional resources