Getting Started with Git and GitHub

John Karahalis, openjck.com

Getting Started with Git and GitHub

Overview

Background

  • What is Git?
  • What is GitHub?

Using Git

  • Setup
  • Starting a Project
  • Changing a File
  • Adding a New File

Using GitHub

  • Setup
  • Publishing Your Project
  • Improving Another Project
  • Accepting an Improvement

Next Steps

  • Learning More
  • Questions

What is Git?

  • Tool for storing a history of changes, publishing those changes, and collaborating with others on making changes
  • Can be used with any files, but most commonly used with source code

What is GitHub?

  • Service that helps developers publish and collaborate on code
  • Can only be used with Git

Git Setup

  1. Use the installer at git-scm.com/download/mac
  2. Download and unzip the example project
  3. Open Terminal
  4. Use cd to navigate to the unzipped project
  5. Set your Git name: git config --global user.name "Your Name"
  6. Set your Git email address: git config --global user.email your-email-address@example.com

Starting a Project

  1. Create a new Git repository: git init
  2. Check the current status: git status
  3. Mark files: git add common-area.jpg event-goal.txt
  4. Check the current status: git status
  5. Store the marked files: git commit
  6. Review: git log

Changing a File

  1. Correct the file event-goal.txt (change five days to three days)
  2. Check the current status: git status
  3. Mark the file: git add event-goal.txt
  4. Store the marked file: git commit
  5. Review: git log

Adding a New File

  1. Create a file called my-project.txt. Make one typo.
  2. Check the current status: git status
  3. Mark the file: git add my-project.txt
  4. Check the current status: git status
  5. Store the marked file: git commit
  6. Review: git log

GitHub Setup

Create a GitHub account

Publishing Your Project

  1. Create a new GitHub repository
  2. Follow the on-screen steps
  3. Refresh the page and browse around

Improving Another Project (Part 1)

  1. On GitHub, fork another person's repository
  2. Copy the "clone URL"
  3. Switch back to Terminal
  4. Navigate outside of the repository: cd ..
  5. Download the fork: git clone [clone URL]
  6. Navigate to the fork: cd [fork folder name]

Improving Another Project (Part 2)

  1. Correct my-project.txt
  2. Check the current status: git status
  3. Mark the file: git add my-project.txt
  4. Check the current status: git status
  5. Store the marked file: git commit
  6. Review: git log
  7. Publish your improvements: git push origin master
  8. Submit a pull request

Accepting an Improvement

  1. On GitHub, visit your project's Pull Requests page
  2. Select the open pull request
  3. Review the improvements
  4. If you like the improvements, click Merge pull request
  5. Download the improvement: git pull origin

Challenge: Improve Kuma

Learning More

GitHub Help (help.github.com) is a great resource for learning more about Git and GitHub

Questions?