Skip to content

An introduction to using Git and GitHub for revision control.

License

Notifications You must be signed in to change notification settings

RobotGarden/github-intro

Repository files navigation

github-class

Installation

Mac OS X

  • Install SourceTree.

Windows

  • Install SourceTree.

  • Install P4Merge.

Initial Setup

SourceTree

  • In Preferences, add your name and email address.

  • Change "Check default remotes for updates" to every 1 minute?

  • Windows users: In Preferences > Diff tab, set P4Merge to your diff and merge tools.

Command Line

  • Set your identity.

    git config --global user.name "John Doe"
    git config --global user.email [email protected]
  • Optionally, set your desired editor for commit messages. Examples:

    git config --global core.editor emacs
    git config --global core.editor "'C:/Program Files/Notepad++/notepad++.exe' -multiInst -nosession"

Getting Help

SourceTree

Command Line

  • git help or git help command

    rivoli:forking-test merose$ git help checkout
    
    GIT-CHECKOUT(1)                   Git Manual                   GIT-CHECKOUT(1)
    
    NAME
           git-checkout - Checkout a branch or paths to the working tree
    
    SYNOPSIS
           git checkout [-q] [-f] [-m] [<branch>]
    ...
  • Pro Git Book

Cloning a Repository

First, go to GitHub and copy the repository URL.

SourceTree * In the repository list (Window > SourceTree), click "+ New Repository" > Clone from URL. * Enter the URL from GitHub and press "Clone".

Command Line * In the directory where you want to create a subdirectory with the cloned repository,

git clone url-copied-from-github

Standalone Workflow

Class Outline

  • Creating a repository

  • Making changes on GitHub

  • Cloning to a local copy

  • Making local changes

  • Committing changes

  • Pushing changes to GitHub

  • Creating a release (talk about tags)

  • Fixing problems: merging from GitHub to local

Exercises

Exercise 1—​Browsing a Repository

  1. On GitHub, browse to the https://github.com/arduino/Arduino repository.

  2. Look at the history for README.md. How many changes have been made this year?

  3. Use the blame view to find out when line 11 was last changed, and by whom.

Creating a New Repository

  1. Create a repository, add a license, and create a README.

  2. Edit the README to add a description.

Exercise 2—​Creating a Repository

  1. Install SourceTree and/or GitHub, and perhaps P4Merge.

  2. Create GitHub account, if needed.

  3. Create a new repository with a license.

  4. Add a README file.

  5. Edit the README.md file to include some text saying this file was created for a GitHub class.

  6. Commit the change to the README.md file.

  7. Turn off the Wiki feature.

  8. Look at the commit history, and view the commit where you edited the README.md file.

Exercise 2

Exercise 3

Exercise 4

Notes

GitHub does not use git-flow: http://scottchacon.com/2011/08/31/github-flow.html. Instead uses GitHub Flow.

To rename files, need to either use git mv or Actions > Move in SourceTree.

Should we talk about submodules? No, too complicated.

License

The materials for this class are licensed under the Apache license. See the file LICENSE for details.

Copyright 2015 Mark Rose

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

About

An introduction to using Git and GitHub for revision control.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published