CyVerse_logo

Home_Icon Learning Center Home

Git for Mere Mortals

Goal

This tutorial will teach the the basics of git using GitHub. You will learn how to create a repository and interact with the GitHub environment through an internet browser and desktop client. The tutorial will briefly introduce some advanced topics.

You can follow along with the rest of this tutorial on your own, or with the corresponding YouTube Video Link will be added once it’s live.


CyVerse_logo

Home_Icon Learning Center Home

CyVerse_logo

Home_Icon Learning Center Home

Cloning, Branching, & Versioning

Description:

In this step, you will learn more advanced skills including cloning a repo, the difference between branching and forking, and how to submit and accept pull requests.


Clone a repo

Online

  1. Click the down arrow “Clone or download”
  2. Click “Open in Desktop”
  3. Select where to save it
    • Create a folder for GitHub repos on your computer locally

Commit

Online

  1. Create a file by clicking “Create a new file”
  2. Name file (/name)
  3. Write commit message
  4. Press “Commit”

Desktop

  1. Create a file and put it in your local GitHub repo
  2. Open Desktop
  3. Fetch origin
  4. Write a commit message & hit commit
  5. Push to origin
  6. See changes on the repo online

Tip

fetch & pull origin (see changes you’ve made online)


Version Control

Online

  1. Click on file
  2. Click “History”

Desktop

  1. Go to repository
  2. Go to branch
  3. Go to “Changes”

Revert to Previous Version

Online

  1. Find the commit you want to revert back to
  2. Click on the unique ID (a series of numbers)
  3. Download the zip file

Note

You can add comments to specific changes by putting the mouse on the change and clicking the “+” button

Desktop

  1. Click on history
  2. Right click on the last commit you want to rever to and select “Revert This Commit”
    • this essentially “undoes” the commit made

Create a branch

Online

  1. Select the down arrow on the repository page that says “Branch:master”
  2. Create a new branch name

OR

  1. Add new file or edit existing file.
  2. Write a commit message.
  3. Select “Create a new branch”

Desktop

  1. Fetch & pull origin
  2. Select “Current branch”, make a “New Branch”, “Publish Branch” (you can see that it has been made online)

Pull request

Online

  1. From your branch, create a new file
  2. Commit file to your branch
  3. Hit “Compare & pull request”
  4. Go to pull requests
  5. “Merge pull request”
  6. Delete branch
  7. See it on the master branch

Desktop

  1. Fetch & pull origin
  2. Select “Current branch”, make a “New Branch”, “Publish Branch” (you can see that it has been made online)

OR

  1. Select a branch if one has already been made
  2. Make changes to a file
  3. Write a commit message & commit
  4. Push to origin
  5. “Create a pull request” (takes you back online)

Tip

pull requests are great to get feedback from collaborators before making a change

Note

that you can always revert back to a previous version

Exercise: Why would pull requests be important?


Merge

Online

  1. Go to “Pull requests”
  2. Select down arrow of “Merge pull request”
  3. Merge, Squash, or Rebase OR ignore
  4. Leave comment if need be
  5. Close pull request

Fork

  1. Go to a new repository
  2. Click fork
  3. Save to personal repository.
  4. Clone to Desktop.
  5. Interact via online or in Desktop.
  6. If want to make suggestions, can create a pull request.

Etc.

  • Versioning
    1. Go to “Releases”
    2. Click “Create a new release”
    3. Tag version: Version #
    4. Release title: I usually put the date of the release, but any system can work
  • Notifications:
    • get notified when there is an issue or pull request created
    • can also “watch” a repository and get updates
  • Badges
    1. Go find a badge!
    2. Copy badge code into README:

Fix or improve this documentation

Github Repo Link

Search for an answer: CyVerse Learning Center

Prerequisites

Downloads, access, and services

In order to complete this tutorial you will need access to the following services/software

Platform(s)

We will use the following CyVerse platform(s):

No CyVerse platforms are needed for this tutorial.

Introduction to Git & GitHub

Definitions

Git - tool for version control.

GitHub - hosted server that is also interactive.

repo - short for repository; GitHub lets you create a remote repository online.

local - on your personal computer.

clone - copy of a repository that lives locally on your computer. Pushing changes will affect the repository online.

fetch - getting latest changes to the repository on your local computer.

branch - parallel to the master branch; allows you to make changes without affecting the master branch. Changes made on a branch can be merged back to the master.

fork - copy of someone else’s repository stored locally on your account. From forks, you can make pull requests to the master branch.

upstream - primary or master branch of original repository.

downstream - branch or fork of repository.

commit - finalize a change.

push - add changes back to the remote repository.

merge - takes changes from a branch or fork and applies them to the master.

pull request - proposed changes to/within a repository.

issue - suggestions or tasks needed for the repository. Allows you to track decisions, bugs with the repository, etc.

Introduction

We will learn how to:

  • create a repository
    • best practices
    • create an issue
    • push/pull files
    • commit to GitHub
  • interact with the GitHub environment
    • using the web interface
    • using GitHub Desktop
  • advanced GitHub
    • branching
    • forking
    • merging
    • versioning

GitHub makes it easy to keep track of changes and has a built in version control.

Background

GitHub Uses

  • Version control
  • Collaborative projects
  • Creating websites
  • Teaching tools
  • Software development
  • Code development

Note

Git is not really for storing or manipulating data, especially large files. But the CyVerse Discovery Environment is a great place to serve, store, and share data.


Fix or improve this documentation

Github Repo Link

Search for an answer: CyVerse Learning Center