Download Class Materials – GitHub App Anatomy



Download Class Materials – GitHub App Anatomy

7 6


intro-to-git

An introduction to git for GDI PGH

On Github LindseyB / intro-to-git

Download Class Materials

http://bit.ly/WMYSB4

Intro to Version Control Using Git

Lindsey Bieda

Introductions

Please ask questions.

Goals for the class

  • Basic understanding of what version control is
  • Basic understanding of git is and how to use it
  • Knowledge of github and what it provides us

Version Control System

A tool that assists in the management of changes to documents.

What does that mean?

  • You can make changes to documents and save those changes.
  • You can undo changes
  • You can include changes from other people*
  • You can multiple change-sets simultaniously*

Not just for programming

Anytime you are working on any set of documents that you are making changes to and want to save the state of version control is extremely useful.

Git

A distributed version control system.

Distributed, in this case, basically means that we can have the same thing existing in multiple locations

GitHub

A web service for programming projects that use Git.

Many Open Source projects hosted here

Collaboration

  • Git makes collaboriton easy
  • GitHub makes collaboration even easier
  • Easy to copy existing code, update, and share updates with others

Tool Check

GitHub

  • If you haven't already create a GitHub account at github.com
  • Login to your account
  • Set your avatar at gravatar.com
  • View your GitHub profile page: http://github.com/your_username

note: for gravatar use the same email your signed up for github with.

GitHub for Mac/Windows

A program that lets us easily use git and github.

Tool Check

GitHub for Mac/Windows

  • If you haven't already download GitHub for Mac/ Windows and install
  • Open GitHub for Mac/Windows
  • Login to your GitHub Account

GitHub App Anatomy

GitHub App Anatomy

GitHub App Anatomy

GitHub App Anatomy

Repository

Where our files live

Also contains:

  • A record of the changes made to those files
  • Who made those changes
  • When those changes were made

Also referred to as a repo for short.

Activity

Our first repository

  • Open the GitHub application
  • Click "add" to create a new repo
  • Give it a name and a description (e.g. "My first repo")

Commit

To save the state of a single or collection of changes.

How to make a commit with git

Whenever you make a change inside the folder where your repo is the GitHub app notices and will ask for a commit message in order to save the changes.

Demonstrate this with the GitHub app.

Commit Message

A note that describes what the commit is about.

Bad Commit Messages

  • Whoops
  • Fixed a thing
  • I have no idea
  • Everything works now
  • I am so angry at the universe right now

Better Commit Messages

  • Added the missing read-me file
  • Fix: Extranous semi-colon removed
  • Moved the cat-pix folder inside the images folder
  • Resolved the problem where content would not display
  • Added a hack in the CSS to fix the bug with IE

Things to keep in mind

  • Avoid being vague
  • Realize that not only are you communicating with future-you, but potientially others
  • When you can, focus on why you did something not what you did

Look at commit messages for https://github.com/LindseyB/intro-to-git

Activity

First commit

  • Open the folder for your repo from the GitHub app
  • Create a new file named "README.md" inside the folder
  • Commit your changes from the GitHub app Make sure to provide a good description for your commit

Syncing

In the command-line world known as pushing

Takes the changes you made on your computer and sends them off to the GitHub website

Activity

Sync your changes

  • Open the GitHub app
  • Click on sync to send your changes to the GitHub website
  • View the changes on GitHub: https://github.com/[username]/[repo name]

A quick note on READMEs

README files are generally provided with software or other files that provides information for the person opening it.

They can contain:

  • How to use a piece of software
  • Who made the software
  • Any bugs in a chunk of software

According to the jargon file the name comes from Lewis Carroll's Alice's Adventures In Wonderland when she encounters "Eat Me" and "Drink Me"

READMEs on GitHub

  • Always will display on the main page on the repo
  • Are important to those viewing the project so they can see what it is about and how to use it
  • Supports the ability to make the content appear with styling using MarkDown
  • Example: reveal.js README

MarkDown

An extremely lightweight markup language.

Reference

MarkDown Example

# Title

* item 1
* item 2
* item 3

*italic text* __bold text__

You Don't Have to Use MarkDown

Plain text will still display perfectly fine

Activity

Add some content to your README

  • Open "README.md" in a text editor
  • Add any content that you desire with or without MarkDown
  • Commit your changes from the GitHub app Make sure to provide a good description for your commit
  • Sync your changes
  • View your new README on the GitHub website https://github.com/[username]/[repo name]

Commits don't need all files

We can tell git that we only want to commit changes to some files rather than all.

When do we want to only commit some files?

  • If we don't want to save our changes in other files.
  • If the other files are in some broken state.
  • If the other files are still "works in progress".

How do we commit only files we want in the GitHub app?

The GitHub app uses checkboxes to let us select which files we want to include as part of our commit.

Activity

Commit only one file

  • Create "NewFile.md"
  • Make some changes in "README.md"
  • Commit your changes from the GitHub app and be sure to only select "NewFile.md".
  • When you click on the commit only this file will show up in the list of changes.

Branch

  • Where your changes live.
  • By deafult you start out in the master branch
  • Difference branches are like parallel universes: they may be very different from one another or very similar and they exist at the same time.
look at https://github.com/rails/rails

Creating a new branch

When we create a new branch we keep all the old files as is, but are able to make changes that don't affect the master branch.

Why would we do this?

  • Working on code we are unsure is correct. (e.g. bug fixes)
  • Working on a completely new version of something.
  • Working on a specific feature we want to add.

How do we create a new branch in the GitHub app?

Demonstrate this with the GitHub app.

How do we view a different branch on GitHub.com?

Demonstrate this with https://github.com/rails/rails

Activity

Creating a new branch

  • Create a new branch named "song"
  • Add any song lyrics to your "README.md" file
  • Commit your changes
  • Sync your changes
  • View your README on the GitHub website https://github.com/[username]/[repo name] note: it will still look the same
  • Change branches on the github website and now look at your README.md file.

Merging

When we take the changes of one branch and pull them into a second branch.

When do we want to merge?

  • When we have tested our new bug fixes and want to use it.
  • When we are ready to go live with new features.
  • When we are ready to go live with a new version.
  • When we want to combine two new features together.

How do we merge in the github app

Demonstrate this with the GitHub app.

Activity

Merging a branch

  • Merge the song branch into the master branch
  • Commit your changes
  • Sync your changes
  • View your README on the GitHub website https://github.com/[username]/[repo name] note: it should now have your song lyrics

Rolling back commits

Sometimes you want to undo a commit, but still keep your changes.

How do we roll back in the github app?

Demonstrate this with the GitHub app.

Reverting a commit

Sometimes you want to completely undo a commit.

How do we revert in the github app?

Demonstrate this with the GitHub app.

Activity

Reverting some changes

  • Open "README.md" and add "Changes I don't want" to it.
  • Open the GitHub app and commit your changes.
  • Now click on the commit from the list and click the revert button.
  • Notice you will now have a new commit that says "Revert..."

Further Learning

Code School - Try Git (command-line based tutorial) Git's official documentation Git Immersion a git walkthrough from the command-line

THE END

Thank you!

Bonus: Activity

Try Git Command-line

  • Open Code School - Try Git.
  • Run through the simple exercises on the web.
  • If you have time, try it on your computer.