98-174 modern version control with gitdogfalo.github.io/git-stuco/week1/week1.pdf · 98-174 modern...

30
98-174 Modern Version Control With Git Shannon Lee Jonathan Miedel Alvin Wang 1

Upload: others

Post on 05-Aug-2020

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 98-174 Modern Version Control With Gitdogfalo.github.io/git-stuco/week1/Week1.pdf · 98-174 Modern Version Control With Git Shannon Lee Jonathan Miedel Alvin Wang 1

98-174 Modern Version Control With Git

Shannon LeeJonathan MiedelAlvin Wang

1

Page 2: 98-174 Modern Version Control With Gitdogfalo.github.io/git-stuco/week1/Week1.pdf · 98-174 Modern Version Control With Git Shannon Lee Jonathan Miedel Alvin Wang 1

Class Logistics● 15 Weeks

○ 13 Lectures○ Midterm + Final

● Class materials hosted on GitHub● For questions raise issues on GitHub or email

us ○ Shannon Lee [email protected]○ Jonathan Miedel [email protected]○ Alvin Wang [email protected]

2

Page 3: 98-174 Modern Version Control With Gitdogfalo.github.io/git-stuco/week1/Week1.pdf · 98-174 Modern Version Control With Git Shannon Lee Jonathan Miedel Alvin Wang 1

Continued● Class website

○ http://dogfalo.github.io/git-stuco/

3

Page 4: 98-174 Modern Version Control With Gitdogfalo.github.io/git-stuco/week1/Week1.pdf · 98-174 Modern Version Control With Git Shannon Lee Jonathan Miedel Alvin Wang 1

Grading● 6 Homeworks (30%)● 1 Midterm (25%)● 1 Final (35%)● Participation (10%)● Do not miss more than 3 classes

4

Page 5: 98-174 Modern Version Control With Gitdogfalo.github.io/git-stuco/week1/Week1.pdf · 98-174 Modern Version Control With Git Shannon Lee Jonathan Miedel Alvin Wang 1

Reasons to Use Version Control Software

● Sharing code● Maintain history of changes

5

Page 6: 98-174 Modern Version Control With Gitdogfalo.github.io/git-stuco/week1/Week1.pdf · 98-174 Modern Version Control With Git Shannon Lee Jonathan Miedel Alvin Wang 1

Problem Scenarios

6

Page 7: 98-174 Modern Version Control With Gitdogfalo.github.io/git-stuco/week1/Week1.pdf · 98-174 Modern Version Control With Git Shannon Lee Jonathan Miedel Alvin Wang 1

Email Echoing● Imagine you are sharing code with your team

members through email…

7

Page 8: 98-174 Modern Version Control With Gitdogfalo.github.io/git-stuco/week1/Week1.pdf · 98-174 Modern Version Control With Git Shannon Lee Jonathan Miedel Alvin Wang 1

Dropbox Duplicates● Picture two people working on the same file

they both save and…

8

Page 9: 98-174 Modern Version Control With Gitdogfalo.github.io/git-stuco/week1/Week1.pdf · 98-174 Modern Version Control With Git Shannon Lee Jonathan Miedel Alvin Wang 1

Investigating Integrity● Pretend a disgruntled employee tampers with

your companies code base making small bugs…

9

Page 10: 98-174 Modern Version Control With Gitdogfalo.github.io/git-stuco/week1/Week1.pdf · 98-174 Modern Version Control With Git Shannon Lee Jonathan Miedel Alvin Wang 1

Feature Fiasco● Recall, those times working on a new feature

before the deadline…

10

Page 11: 98-174 Modern Version Control With Gitdogfalo.github.io/git-stuco/week1/Week1.pdf · 98-174 Modern Version Control With Git Shannon Lee Jonathan Miedel Alvin Wang 1

Version Control● “The management of changes to documents,

computer programs, large web sites, and other collections of information” - Wikipedia

● Version Control Software (VCS) is any software that aids in the above tasks

11

Page 12: 98-174 Modern Version Control With Gitdogfalo.github.io/git-stuco/week1/Week1.pdf · 98-174 Modern Version Control With Git Shannon Lee Jonathan Miedel Alvin Wang 1

Advantages● Allows for parallel programing (code sharing)● Maintain multiple versions ● Backup work● Allow to view history● Revert changes● Speeds up development by allowing you to

make errors12

Page 13: 98-174 Modern Version Control With Gitdogfalo.github.io/git-stuco/week1/Week1.pdf · 98-174 Modern Version Control With Git Shannon Lee Jonathan Miedel Alvin Wang 1

Introduction to Git● Source code management software● Distributed workflow● Free and open source

13

Page 14: 98-174 Modern Version Control With Gitdogfalo.github.io/git-stuco/week1/Week1.pdf · 98-174 Modern Version Control With Git Shannon Lee Jonathan Miedel Alvin Wang 1

Features of Git● Operates faster than most competitors● Easy to use (particularly branching)● One of the most common in industry

○ As of April 2014, there were 247,103 repositories (https://www.openhub.net/repositories/compare)

● Offers data assurance

14

Page 15: 98-174 Modern Version Control With Gitdogfalo.github.io/git-stuco/week1/Week1.pdf · 98-174 Modern Version Control With Git Shannon Lee Jonathan Miedel Alvin Wang 1

Installing GitWindows: http://git-scm.com/download/winMac: http://git-scm.com/download/macLinux (Ubuntu): sudo apt-get install git

15

Page 16: 98-174 Modern Version Control With Gitdogfalo.github.io/git-stuco/week1/Week1.pdf · 98-174 Modern Version Control With Git Shannon Lee Jonathan Miedel Alvin Wang 1

Setting up Git

$ git config --global user.name "Alvin Wang"

$ git config --global user.email [email protected]

16

Page 17: 98-174 Modern Version Control With Gitdogfalo.github.io/git-stuco/week1/Week1.pdf · 98-174 Modern Version Control With Git Shannon Lee Jonathan Miedel Alvin Wang 1

Introduction to GitHub● github.com

○ Create a new account and login○ Sign up for GitHub!!!!○ Confirm your email

17

Page 18: 98-174 Modern Version Control With Gitdogfalo.github.io/git-stuco/week1/Week1.pdf · 98-174 Modern Version Control With Git Shannon Lee Jonathan Miedel Alvin Wang 1

Creating a Repo within GitHub

18

Page 19: 98-174 Modern Version Control With Gitdogfalo.github.io/git-stuco/week1/Week1.pdf · 98-174 Modern Version Control With Git Shannon Lee Jonathan Miedel Alvin Wang 1

How to Clone a Repositorygit clone - clones a repository (creates the local copy in the current directory)

19

$ git clone <git-repo-link>

Page 20: 98-174 Modern Version Control With Gitdogfalo.github.io/git-stuco/week1/Week1.pdf · 98-174 Modern Version Control With Git Shannon Lee Jonathan Miedel Alvin Wang 1

2048 Example

20

Page 21: 98-174 Modern Version Control With Gitdogfalo.github.io/git-stuco/week1/Week1.pdf · 98-174 Modern Version Control With Git Shannon Lee Jonathan Miedel Alvin Wang 1

How to Create a Repositorygit init - initializes a blank Git repository in the current directory$ git clone <git-repo-link>$ git clone <git-repo-link>

21

Page 22: 98-174 Modern Version Control With Gitdogfalo.github.io/git-stuco/week1/Week1.pdf · 98-174 Modern Version Control With Git Shannon Lee Jonathan Miedel Alvin Wang 1

Workflow Diagram

22

Page 23: 98-174 Modern Version Control With Gitdogfalo.github.io/git-stuco/week1/Week1.pdf · 98-174 Modern Version Control With Git Shannon Lee Jonathan Miedel Alvin Wang 1

git add● Takes a “snapshot” of

your files and puts it in the staging area

git add

23

Page 24: 98-174 Modern Version Control With Gitdogfalo.github.io/git-stuco/week1/Week1.pdf · 98-174 Modern Version Control With Git Shannon Lee Jonathan Miedel Alvin Wang 1

git add options● adds files to the index● git add <filename>● git add **/*.js (adds only javascript files)● git add . (adds all changes and additions in current

folder + subdirectories and adds deletions in 2.0+)● git add -A (same as git add --all, adds deletions too)● In git 2.0, git add -A and -u operate on the entire tree,

rather than just the current directory and subdirectories

24

Page 25: 98-174 Modern Version Control With Gitdogfalo.github.io/git-stuco/week1/Week1.pdf · 98-174 Modern Version Control With Git Shannon Lee Jonathan Miedel Alvin Wang 1

git status● git status - shows you what files in your

repository have been changed, deleted, or added

25

Page 26: 98-174 Modern Version Control With Gitdogfalo.github.io/git-stuco/week1/Week1.pdf · 98-174 Modern Version Control With Git Shannon Lee Jonathan Miedel Alvin Wang 1

git commit● Commits your staged

(git add) changes to your repository

git commitgit add

26

Page 27: 98-174 Modern Version Control With Gitdogfalo.github.io/git-stuco/week1/Week1.pdf · 98-174 Modern Version Control With Git Shannon Lee Jonathan Miedel Alvin Wang 1

Opening Issues on GithubFor this class we will handle questions by having you open issues on GitHub. This will help you get more familiar with the Git workflow.https://github.com/Git-Stuco/GitStucoClass

27

Page 28: 98-174 Modern Version Control With Gitdogfalo.github.io/git-stuco/week1/Week1.pdf · 98-174 Modern Version Control With Git Shannon Lee Jonathan Miedel Alvin Wang 1

Homework● Fill out survey (2 mins)

○ http://goo.gl/veEcTn● Clone the week 1 repo

○ https://github.com/Git-Stuco/Week1● Follow link in repository to video (5 mins)

28

Page 29: 98-174 Modern Version Control With Gitdogfalo.github.io/git-stuco/week1/Week1.pdf · 98-174 Modern Version Control With Git Shannon Lee Jonathan Miedel Alvin Wang 1

Next Week in 98-174Basic Git Commands● Clone in Detail● Commits as a concept● Push● git log● History of Git

29

Page 30: 98-174 Modern Version Control With Gitdogfalo.github.io/git-stuco/week1/Week1.pdf · 98-174 Modern Version Control With Git Shannon Lee Jonathan Miedel Alvin Wang 1

Questions

30