56
Technical Workshop I Introduction to GitHub

Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

Technical Workshop I

Introduction to GitHub

Page 2: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

Prerequisites

● Bring laptop● Make a GitHub account● Download and Install Git

Page 3: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

Why is GitHub important?

● Using GitHub for○ Hackathons○ Personal projects○ Industry

● Version Control

Page 4: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

Git vs. GitHub

● Git○ Version control system○ Tool to manage source

code history

● GitHub○ Hosting service for Git

repositories○ Service for projects using

Git○ Task management, bug

tracking, and feature requests

Page 5: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

Learning Example: Tic-Tac-Toe

Page 6: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

Creating Remote

RepositoryNavigate to www.github.com and

login to your account

Page 7: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

Creating Remote

Repository

Page 8: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

Creating Remote

Repository

Page 9: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

Creating Local Repository

GitHub gives us the code, but first let’s understand it

Page 10: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

git init

Page 11: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

git add

Page 12: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

git commit

Page 13: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

git status

Page 14: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

Lets try it out!

Page 15: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

Lets try it out!

Page 16: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

Lets try it out!

Page 17: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

Lets try it out!

Page 18: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

Why are the files not showing up on GitHub?

● Our local repository is not yet connected to our remote repository

● How do we fix this problem?○ We have to connect the local and remote repositories○ Then push our local files to the remote○ To do this, we need a couple more commands

■ git remote ■ git push

Page 19: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

git remote

Page 20: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

git push

Page 21: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

Lets try it out!

Tip: remote url is the GitHub repository URL in the browser with .git at the end!

Page 22: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

Lets try it out!

Page 23: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

What are Branches?

● A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're given a master branch that points to the last commit you made.

● To work with branches in git, we need to learn several more commands○ git branch○ git checkout

Page 24: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

git branch

Page 25: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

git checkout

Page 26: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

Lets try it out!

Page 27: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

Lets try it out!

Tip: the * in front of game lets us know we are currently on that branch!

Page 28: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

So we have a branch now what?

● Time to make our tic-tac-toe game!○ Don’t have time to make from scratch○ So we need to learn how to fork a repository

■ A fork is simply a clone of some repository that you work on without affecting the repository you got it from

○ We will need a new command to fork■ git pull

Page 29: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

git pull

Page 30: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

Lets try it out!

First we need to connect to the remote that we will pull the unfinished game from

Remote URL: https://github.com/bethqiang/tic-tac-toe.git

Page 31: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

Lets try it out!

We use the --allow-unrelated-histories flag since no commits are similar between our branch and the master branch of the finished game

We got a merge conflict with the README.md file, lets see how to fix that

Page 32: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

Dealing with merge conflicts

Our README.md file looks very different now, git pull attempted to merge our README.md and the README.md from the finished game

Page 33: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

Dealing with merge conflicts

<<<<<<< HEAD is the start of our README.md======= marks the split of our README.md from the one we got from the finished game>>>>>>> 83ed...262 marks the end of the README.md we got from the finished game

Page 34: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

Dealing with merge conflicts

Delete from the file whichever parts you don't want to keep and then git add and git commit

Page 35: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

Dealing with merge conflicts

Page 36: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

Checking what we have on GitHub

It appears nothing has changed on GitHub why is that?

Page 37: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

Checking what we have on GitHub

We have to switch branches to see what is in the game branch

Page 38: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

Checking what we have on GitHub

Now we see the tic-tac-toe game files we pulled in

Page 39: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

How does the game look?

Open the index.html file from your local repository to try playing!

Page 40: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

Lets modify the game!

● Create a branch where we will work on the change● Once change is done we will merge it back into our

game branch● To do this we will need a new command

○ git merge

Page 41: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

git merge

Page 42: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

Lets try it out!

Created and switched to a branch named style_update

Page 43: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

Lets try it out!

Open the style.css file this is where the styling for the game is kept

Page 44: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

Lets try it out!

We are going to modify the color of the X’s and O’s

Make sure to save the file afterwards

Page 45: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

Lets see how it looks now!

Page 46: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

How do we merge it into our game branch?

Before we can merge the changes with our game branch we need to add and commit the changes

Page 47: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

How do we merge it into our game branch?

First we need to switch into the game branchThen we can use git merge style_update to merge in the changes between both commits

Page 48: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

Cleaning up the branches

Now that we are done with the style_update branch we can delete it with the -d flag

Page 49: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

Updated game not on GitHub?

We have to push our commit in order to update the local repository

Page 50: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

Finishing touches

● We need to merge the master branch with the game branch

● Look into GitHub issue tracking

Page 51: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

Lets try it out!

Merged game branch into master and then pushed

Page 52: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

Issue Tracking

● Allows you to assign issues to yourself and or collaborators● Keep track of issues and mark when they are resolved● Mark issues with specific tags like help wanted or beginner

friendly

Page 53: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

How to use Issues in GitHub

Page 54: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

How to use Issues in GitHub

Page 55: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

How to use Issues in GitHub

Page 56: Technical Workshop I - USF · A branch in Git is simply a lightweight, movable pointer to a commit. The default branch name in Git is master. As you initially make commits, you're

Thanks for coming!