0% found this document useful (0 votes)
103 views33 pages

CSE4006: Software Engineering: Lab 2: Git

Uploaded by

Vince Kao
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
103 views33 pages

CSE4006: Software Engineering: Lab 2: Git

Uploaded by

Vince Kao
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 33

CSE4006: Software Engineering

Lab 2: Git
Software Engineering Lab

Except where otherwise noted, the contents of this document are Copyright 2017 Gayeon Kim, Gwanggyu Choi,
Youn-geun Ahn 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.
Review
Git Basic Workflow
git add git commit git push
git init

Local Remote
Workspace Staging Area
Repository Repository

git pull (or rebase)


Review
git init
Workspace

Your
Project .git

Initialize workspace under Git


Review
.git
.git
Staging Area(Index)

Git project settings


(config, remote ref, …)

Initialize workspace under Git


Review
git remote add
.git
Remote repository names
selab:
https://github.com/.../se2017.git
myRepo:
https://github.com/.../frebern.git

Naming remote repository reference


Review
git pull

merge Local fetch


Workspace Remote Repository
Repository (GitHub, BitBucket …)

e.g. git pull myRepo master

Copy & Merge repository from remote to workspace


Review
git add

Workspace Staging Area

e.g. git add *

Record changes(modifications) to staging area


Review
git commit

Local
Staging Area
Repository

e.g. git commit –m “This is Commit Message”

Merge recorded changes to local repository


Review
git push

Local Repository Remote Repository


(GitHub, BitBucket …)

e.g. git push myRepo master

Copy & Merge repository from local to remote


Fork(Contributors)

It may be PM’s repository in this class

If you want to contribute to a project,


you can perform ‘fork’
Fork(Contributors)
‘Fork’ will copy the original project
to your own repository
Pull Request
• Meaning of ‘Pull Request’

Pull me!
My remote Project
Repository Repository
Okay!

“Please Pull(reflect) me!”


Pull Request(My Repo  Project Repo)
In my repository

Click
Pull Request(My Repo  Project Repo)

If you have some changes(and no conflicts) with project repository,


then you can do ‘Create pull request’
Pull Request(My Repo  Project Repo)

PM can accept/reject
contributor’s Pull Request

Accept(Merge)
Reject(Close)
Pull Request(Project Repo  My Repo)
In my repository

Click
Pull Request(Project Repo  My Repo)

Click
When the changes are occur at project repository,
then you need to synchronize your repository and project repository
Pull Request(Project Repo  My Repo)

When you click ‘switching the base’, then the pull direction is reversed.
(From Project Repository to My Repository)
Exercise 1
1. Fork or Pull TA’s repository to your remote repository
(https://github.com/SELab2017/SE2017.git)

2. Pull your remote repository to your local repository


(see lab1.pdf)

3. Add your directory and txt file with your name


(e.g. Week2_AhnYounGeun/Week2_AhnYounGeun.txt)

4. Commit & Push your local repository to your remote repository


(also see lab1.pdf)

5. Send ‘Pull Request’ to your remote repository to TA’s repository


Git - Conflict
master Hello Conflict
push
pull (or pull request) push
pull
(or pull request)
ahn hello

kim HELLO

• Generally Git used in a project with multiple developers(Contributors)


• When the same file is modified by different developers at the same time,
‘conflict’ occur.
• Hence, such conflict must be well managed.
Git - Conflict
master Hello
pull push
push (or pull request)
pull (or pull request)

ahn hello

kim HELLO

Solution 1: Just synchronize frequently


(The person who commits late has all faults.)
Git - Conflict
master Hello hello
pull push
(pull request) pull push
pull (pull request)

ahn hello

working…
kim HELLO Conflict HELLO
Solve Conflict
(select hello or HELLO)

Solution 2: Solve Conflict Locally


(Master don’t have any responsibilities to solve conflict)
Git - Solve Conflict
Solution 2: Solve Conflict Locally
Git - Solve Conflict
Solution 2: Solve Conflict Locally

git diff: Where is conflict?


Git - Solve Conflict
Solution 2: Solve Conflict Locally

Fix here!
Remain ‘This line is added from my PC’
or ‘This line is added from GitHub’

Select HEAD or 932e9…(GitHub master branch)


Git - Solve Conflict
Solution 2: Solve Conflict Locally

I selected ‘This line is added from my PC.’


(You can also select another one.)

Select HEAD or 932e9…(GitHub master branch)


Team Building
• 5~6 people in One team
• 5 Teams
Team 1 Team 2 Team 3 Team 4 Team 5
Exercise 2-1 (Teamwork)
• Solve Conflict Scenario
1. 3명의 개발자가 PM의 레포지터리를 Fork합니다.
2. 각자 작업을 끝내고 PM에게 Pull Request를 보냅니다.
3. Pull Request#1은 A.txt와 B.txt를 수정했습니다.
4. Pull Request#2는 B.txt와 C.txt를 수정했습니다.
5. Pull Request#3는 A.txt와 C.txt를 수정했습니다.
6. PM은 순서대로 Merge하지만 Conflict가 발생하게 됩니다.
7. 이 때, 발생하는 Conflict를 전부 설명하고, 해결책을 설명하세요.
Exercise 2-2 (Teamwork)
• Solve Conflict Scenario
1. 2명의 개발자가 PM의 레포지터리를 Fork합니다.
2. PM은 A.txt, B.txt, C.txt를 수정 후 Push합니다.
3. 2명의 개발자가 작업을 끝내고 PM에게 Pull Request를 보냅니다.
4. Pull Request#1은 A.txt와 B.txt를 수정했습니다.
5. Pull Request#2는 B.txt와 C.txt를 수정했습니다.
6. PM은 이후 순서대로 Merge하지만 Conflict가 발생하게 됩니다.
7. 이 때, 발생하는 Conflict를 전부 설명하고, 해결책을 설명하세요.
Exercise 2-3 (Teamwork)
• Solve Conflict Scenario
1. 2명의 개발자가, PM의 레포지터리를 Fork 합니다.
2. 개발자 1은 PM의 레포지터리에서 로컬 레포지터리로
Pull을 한 후, A.txt를 수정합니다(hint: Triangular Workflow).
3. 개발자 2는 자신의 원격 레포지터리에서 로컬 레포지터리로
Pull을 한 후, A.txt를 수정합니다.
4. 개발자 2는 자신의 원격 레포지터리로 작업내용을 Push 후,
PM에게 Pull Request#1을 보냅니다.
5. PM은 개발자 2의 Pull Request#1을 확인 후 Merge 합니다.
6. 그 후, 개발자 1도 자신의 레포지터리로 작업내용을 Push 후,
PM에게 Pull Request#2를 보냅니다.
7. 이 때, 발생하는 Conflict를 전부 설명하고, 해결책을 설명하세요.
Exercise 2-4 (Teamwork)
• Solve Conflict Scenario
1. 여러 명의 개발자가, A라는 프레임워크(e.g. Unity, Android, Unreal, etc.…)
를 사용하는 프로젝트를 진행합니다.
2. A 프레임워크는 경로나 환경변수 등 개발자마다 환경이 다르기 때문에,
어떤 설정 파일의 내용도 구조도 개발자마다 달라집니다.
3. 이러한 설정들은 IDE에서 자동으로 해주기 때문에,
개발자는 어느 파일이 이러한 설정들을 담고 있는지 알 수 없습니다.
(최악의 경우, 이러한 설정 파일들은 완전히 파편화 되어 있을 수도 있습니다.)
4. 개발자들이 자신의 프로젝트를 통째로 저장해서 Pull Request를 보낸다
면 각종 문제가 발생하게 됩니다.
5. 이 때, 발생할 수 있는 문제들을 설명하고, 해결책을 설명하세요.
Exercise 2-5 (Teamwork)
• Solve Conflict Scenario
1. 3명의 개발자가 PM의 레포지터리를 Fork합니다.
2. 각자 작업을 끝내고 PM에게 Pull Request를 보냅니다.
3. Pull Request#1은 A.txt를 수정했습니다.
4. Pull Request#2는 B.txt를 수정했습니다.
5. Pull Request#3는 C.txt를 수정했습니다.
6. PM은 순서대로 충돌 없이 성공적으로 Merge합니다.
7. 하지만 나중에, B.txt의 수정사항에 문제가 있음을 발견하고,
PM은 B.txt만 이전 버전으로 되돌리고자 합니다.
8. 이 때, 발생할 수 있는 문제들을 설명하고, 해결책을 설명하세요.
Exercise 2
• Select & Solve one scenario for each team.
• Tell your solution at 3/22(tentative)
Team 1 Team 2 Team 3 Team 4 Team 5

You might also like