Lab 1: Git - Hanyang · 2020. 3. 26. · 1. git init 2. git remote add [repoName] [url] 3. git pull...

28
Lab 1: Git Software Engineering Lab CSE406: Software Engineering Except where otherwise noted, the contents of this document are Copyright 2020 Gayeon Kim, Gwanggyu Choi, Youn- geun Ahn, Hakjin Lee and Scott Uk-Jin Lee All rights reserved. Any redistribution, reproduction, transmission, or storag e of part or all of the contents in any form is prohibited without author’s expressed written permission.

Transcript of Lab 1: Git - Hanyang · 2020. 3. 26. · 1. git init 2. git remote add [repoName] [url] 3. git pull...

Page 1: Lab 1: Git - Hanyang · 2020. 3. 26. · 1. git init 2. git remote add [repoName] [url] 3. git pull [repoName] [branch(e.g. master)] 4. Working… 5. git add * 6. git commit –m

Lab 1: Git

Software Engineering Lab

CSE406: Software Engineering

Except where otherwise noted, the contents of this document are Copyright 2020 Gayeon Kim, Gwanggyu Choi, Youn-geun Ahn, Hakjin Lee and Scott Uk-Jin Lee All rights reserved. Any redistribution, reproduction, transmission, or storage of part or all of the contents in any form is prohibited without author’s expressed written permission.

Page 2: Lab 1: Git - Hanyang · 2020. 3. 26. · 1. git init 2. git remote add [repoName] [url] 3. git pull [repoName] [branch(e.g. master)] 4. Working… 5. git add * 6. git commit –m

Git

Page 3: Lab 1: Git - Hanyang · 2020. 3. 26. · 1. git init 2. git remote add [repoName] [url] 3. git pull [repoName] [branch(e.g. master)] 4. Working… 5. git add * 6. git commit –m

VCS(Version Control System)

Database for ‘Version’

Page 4: Lab 1: Git - Hanyang · 2020. 3. 26. · 1. git init 2. git remote add [repoName] [url] 3. git pull [repoName] [branch(e.g. master)] 4. Working… 5. git add * 6. git commit –m

Why use VCS?

• Collaboration

• Backup

• Tracking source code

• Tracking what happened

• Reduce side-effectwhen you develope a new module

Page 5: Lab 1: Git - Hanyang · 2020. 3. 26. · 1. git init 2. git remote add [repoName] [url] 3. git pull [repoName] [branch(e.g. master)] 4. Working… 5. git add * 6. git commit –m

Centralized Version Control

Remote Team Repository(SVN)

Work Space(PC

)

Page 6: Lab 1: Git - Hanyang · 2020. 3. 26. · 1. git init 2. git remote add [repoName] [url] 3. git pull [repoName] [branch(e.g. master)] 4. Working… 5. git add * 6. git commit –m

Distributed VC(Team-Scale)

Remote TeamRepository(Github)

Local Repository(PC)

Work Space(PC)

Page 7: Lab 1: Git - Hanyang · 2020. 3. 26. · 1. git init 2. git remote add [repoName] [url] 3. git pull [repoName] [branch(e.g. master)] 4. Working… 5. git add * 6. git commit –m

Distributed VC(Project-Scale)

Local Repository(PC)

Remote Project Repository(Github)

Remote Team Repository(Github)

Local Repository(PC)

Page 8: Lab 1: Git - Hanyang · 2020. 3. 26. · 1. git init 2. git remote add [repoName] [url] 3. git pull [repoName] [branch(e.g. master)] 4. Working… 5. git add * 6. git commit –m

Git Workflow

(Staging Area)

Page 9: Lab 1: Git - Hanyang · 2020. 3. 26. · 1. git init 2. git remote add [repoName] [url] 3. git pull [repoName] [branch(e.g. master)] 4. Working… 5. git add * 6. git commit –m

Git Install

• OS X• http://sourceforge.net/projects/git-osx-installer/

• Windows• https://git-scm.com/download/win

• Linux• $ apt-get install git

Page 10: Lab 1: Git - Hanyang · 2020. 3. 26. · 1. git init 2. git remote add [repoName] [url] 3. git pull [repoName] [branch(e.g. master)] 4. Working… 5. git add * 6. git commit –m

Github

• Sign up https://github.com

Click

Page 11: Lab 1: Git - Hanyang · 2020. 3. 26. · 1. git init 2. git remote add [repoName] [url] 3. git pull [repoName] [branch(e.g. master)] 4. Working… 5. git add * 6. git commit –m

Github

• Sign up

Click

Page 12: Lab 1: Git - Hanyang · 2020. 3. 26. · 1. git init 2. git remote add [repoName] [url] 3. git pull [repoName] [branch(e.g. master)] 4. Working… 5. git add * 6. git commit –m

Github

• Sign up

Click

Page 13: Lab 1: Git - Hanyang · 2020. 3. 26. · 1. git init 2. git remote add [repoName] [url] 3. git pull [repoName] [branch(e.g. master)] 4. Working… 5. git add * 6. git commit –m

Github

• Sign up

Page 14: Lab 1: Git - Hanyang · 2020. 3. 26. · 1. git init 2. git remote add [repoName] [url] 3. git pull [repoName] [branch(e.g. master)] 4. Working… 5. git add * 6. git commit –m

Github

• Sign up

Click

Check your Email

Page 15: Lab 1: Git - Hanyang · 2020. 3. 26. · 1. git init 2. git remote add [repoName] [url] 3. git pull [repoName] [branch(e.g. master)] 4. Working… 5. git add * 6. git commit –m

Github

• Create new remote repository

Click (if you are already registered in GitHub)

Click (if you are new GitHub user)

Page 16: Lab 1: Git - Hanyang · 2020. 3. 26. · 1. git init 2. git remote add [repoName] [url] 3. git pull [repoName] [branch(e.g. master)] 4. Working… 5. git add * 6. git commit –m

Github

Repository Name

Click

Click

Page 17: Lab 1: Git - Hanyang · 2020. 3. 26. · 1. git init 2. git remote add [repoName] [url] 3. git pull [repoName] [branch(e.g. master)] 4. Working… 5. git add * 6. git commit –m

Github

Click

Remote Repository URL

Click

Page 18: Lab 1: Git - Hanyang · 2020. 3. 26. · 1. git init 2. git remote add [repoName] [url] 3. git pull [repoName] [branch(e.g. master)] 4. Working… 5. git add * 6. git commit –m

Git - Work Space

Use git bash (Mac user can use terminal)

(your local workspace)

Click

Page 19: Lab 1: Git - Hanyang · 2020. 3. 26. · 1. git init 2. git remote add [repoName] [url] 3. git pull [repoName] [branch(e.g. master)] 4. Working… 5. git add * 6. git commit –m

Git - Work Space

git init

Set current directory to

Git workspace

Page 20: Lab 1: Git - Hanyang · 2020. 3. 26. · 1. git init 2. git remote add [repoName] [url] 3. git pull [repoName] [branch(e.g. master)] 4. Working… 5. git add * 6. git commit –m

Git - Work Space

git config

git config sets your user information which is usedfor authentication to access private remote repository.

Page 21: Lab 1: Git - Hanyang · 2020. 3. 26. · 1. git init 2. git remote add [repoName] [url] 3. git pull [repoName] [branch(e.g. master)] 4. Working… 5. git add * 6. git commit –m

Git - Work Space

git remote add / git pullNaming Remote Repository(insert yours https://github.com/YourID/YourRepoName.git)

git pull origin master

Pull from remote repo

README.md pulled

* Pull = Fetch + Merge(i.e. Receive current remote repository

+ Merge them to my local repository)

Page 22: Lab 1: Git - Hanyang · 2020. 3. 26. · 1. git init 2. git remote add [repoName] [url] 3. git pull [repoName] [branch(e.g. master)] 4. Working… 5. git add * 6. git commit –m

Git - Staging Area

.git

‘.git’ has index of files and changes.

Page 23: Lab 1: Git - Hanyang · 2020. 3. 26. · 1. git init 2. git remote add [repoName] [url] 3. git pull [repoName] [branch(e.g. master)] 4. Working… 5. git add * 6. git commit –m

Git - Staging Area

git status

Display current HEAD commit

& Tracked/Untracked files

Page 24: Lab 1: Git - Hanyang · 2020. 3. 26. · 1. git init 2. git remote add [repoName] [url] 3. git pull [repoName] [branch(e.g. master)] 4. Working… 5. git add * 6. git commit –m

Git - Staging Area

Add file to Staging Area(index)

you can use * (if you want add all

files(fixed or new))

git add

Page 25: Lab 1: Git - Hanyang · 2020. 3. 26. · 1. git init 2. git remote add [repoName] [url] 3. git pull [repoName] [branch(e.g. master)] 4. Working… 5. git add * 6. git commit –m

Git - Local Repository

git commit

Commit all added changes & save to Local Repository

git commit –m “Your commit log or message”

Page 26: Lab 1: Git - Hanyang · 2020. 3. 26. · 1. git init 2. git remote add [repoName] [url] 3. git pull [repoName] [branch(e.g. master)] 4. Working… 5. git add * 6. git commit –m

Git - Remote Repository

git push

hello.txt added to Remote repository

Push Local to Remote

Page 27: Lab 1: Git - Hanyang · 2020. 3. 26. · 1. git init 2. git remote add [repoName] [url] 3. git pull [repoName] [branch(e.g. master)] 4. Working… 5. git add * 6. git commit –m

Basic Work Flow

1. git init

2. git remote add [repoName] [url]

3. git pull [repoName] [branch(e.g. master)]

4. Working…

5. git add *

6. git commit –m “commit message”

7. git push [repoName] [branch(e.g. master)]

8. Repeat 3~7

Page 28: Lab 1: Git - Hanyang · 2020. 3. 26. · 1. git init 2. git remote add [repoName] [url] 3. git pull [repoName] [branch(e.g. master)] 4. Working… 5. git add * 6. git commit –m

Exercise

1. Create an remote repository

2. Pull remote repository to your workspace.(if you can’t pull them, try --allow-unrelated-histories option)

3. Create a program It’s double dash - -

Ex) if you input “1” then print your name.

4. Add & Commit to local repository

5. Push them to remote repository(if you can’t push them, try -f option)

6. Add functionwhich print your introduce when you input “2”

7. Update your remote repository