[Sprint] Simple Git Workflow 실습

sprint-simple-git-workflow

⬛ Fork

Sprint Repository 를 복사

⬛ Clone

각자 Local Repository 로 Remote Repository 를 복제

⬛ Remote Add Pair

Pair 의 Remote Repository 를 add

⬛ Commit

소스 파일 수정 후 Commit

⬛ Push

Commit, Staging 한 파일을 Push

⬛ Pull

Pair 가 올린 파일을 Pull 해서 내려 받기

⬛ 역할을 변경하여 Push, Pull 작업을 수행하기 (repeat)

⬛ 전체 Workflow Script

 원본 sprint-simple-git-workflow clone 진행
user01@ubuntu:~/다운로드$ git clone git@github.com:Park-ChanKyu/sprint-simple-git-workflow.git
'sprint-simple-git-workflow'에 복제합니다...
remote: Enumerating objects: 9, done.
remote: Total 9 (delta 0), reused 0 (delta 0), pack-reused 9
오브젝트를 받는 중: 100% (9/9), 완료.
델타를 알아내는 중: 100% (1/1), 완료.

 Add pair`s fork as remote 진행
user01@ubuntu:~/다운로드/sprint-simple-git-workflow$ git remote add pair git@github.com:taekyung-oh/sprint-simple-git-workflow.git
user01@ubuntu:~/다운로드/sprint-simple-git-workflow$ git remote -v
origin	git@github.com:Park-ChanKyu/sprint-simple-git-workflow.git (fetch)
origin	git@github.com:Park-ChanKyu/sprint-simple-git-workflow.git (push)
pair	git@github.com:taekyung-oh/sprint-simple-git-workflow.git (fetch)
pair	git@github.com:taekyung-oh/sprint-simple-git-workflow.git (push)
 Push your code to your remote orgin
user01@ubuntu:~/다운로드/sprint-simple-git-workflow$ git add ./bighead 
user01@ubuntu:~/다운로드/sprint-simple-git-workflow$ git commit -m bighead
[master 7686a7c] bighead
 1 file changed, 1 insertion(+)
 create mode 100644 bighead
user01@ubuntu:~/다운로드/sprint-simple-git-workflow$ git push origin master 
오브젝트 나열하는 중: 7, 완료.
오브젝트 개수 세는 중: 100% (7/7), 완료.
오브젝트 압축하는 중: 100% (4/4), 완료.
오브젝트 쓰는 중: 100% (6/6), 586 바이트 | 146.00 KiB/s, 완료.
Total 6 (delta 0), reused 0 (delta 0), pack-reused 0
To github.com:Park-ChanKyu/sprint-simple-git-workflow.git
   67bc313..7686a7c  master -> master
 Pull pair`s code to local repository
user01@ubuntu:~/다운로드/sprint-simple-git-workflow$ git pull pair master
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 3 (delta 0), pack-reused 0
오브젝트 묶음 푸는 중: 100% (3/3), 263 바이트 | 263.00 KiB/s, 완료.
github.com:taekyung-oh/sprint-simple-git-workflow URL에서
 * branch            master     -> FETCH_HEAD
 * [새로운 브랜치]   master     -> pair/master
업데이트 중 67bc313..5a3f5cf
Fast-forward
 simpleGit.txt | 1 +
 1 file changed, 1 insertion(+)
 create mode 100644 simpleGit.txt

⬛ 충돌 테스트

 Colision Test
user01@ubuntu:~/다운로드/sprint-simple-git-workflow$ git pull pair master
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (1/1), done.
remote: Total 3 (delta 1), reused 3 (delta 1), pack-reused 0
오브젝트 묶음 푸는 중: 100% (3/3), 239 바이트 | 14.00 KiB/s, 완료.
github.com:taekyung-oh/sprint-simple-git-workflow URL에서
 * branch            master     -> FETCH_HEAD
   5a3f5cf..2a75ad4  master     -> pair/master
힌트: You have divergent branches and need to specify how to reconcile them.
힌트: You can do so by running one of the following commands sometime before
힌트: your next pull:
힌트: 
힌트:   git config pull.rebase false  # merge (the default strategy)
힌트:   git config pull.rebase true   # rebase
힌트:   git config pull.ff only       # fast-forward only
힌트: 
힌트: You can replace "git config" with "git config --global" to set a default
힌트: preference for all repositories. You can also pass --rebase, --no-rebase,
힌트: or --ff-only on the command line to override the configured default per
힌트: invocation.
fatal: Need to specify how to reconcile divergent branches.
# Pull 과정에서 merge 방법을 선택해야 한다는 메시지가 출력됨
# merge mode 로 설정
user01@ubuntu:~/다운로드/sprint-simple-git-workflow$ git config pull.rebase false

user01@ubuntu:~/다운로드/sprint-simple-git-workflow$ git pull pair master
github.com:taekyung-oh/sprint-simple-git-workflow URL에서
 * branch            master     -> FETCH_HEAD
자동 병합: simpleGit.txt
충돌 (내용): simpleGit.txt에 병합 충돌
자동 병합이 실패했습니다. 충돌을 바로잡고 결과물을 커밋하십시오.

# 충돌 해결 과정
user01@ubuntu:~/다운로드/sprint-simple-git-workflow$ cat ./simpleGit.txt 
<<<<<<< HEAD
ABC
2023-03-21 PARK-CHAN-KYU
=======
BADEC
>>>>>>> 2a75ad4c8641611276186465bc8546119dc76899
# 아래와 같이 수정
user01@ubuntu:~/다운로드/sprint-simple-git-workflow$ cat ./simpleGit.txt 
ABC
2023-03-21 PARK-CHAN-KYU
BADEC

# 수정 완료 후 정상동작 확인
user01@ubuntu:~/다운로드/sprint-simple-git-workflow$ git add ./simpleGit.txt 
user01@ubuntu:~/다운로드/sprint-simple-git-workflow$ git commit -m simpleGit.txt 
[master d06e693] simpleGit.txt
user01@ubuntu:~/다운로드/sprint-simple-git-workflow$ git push master origin
fatal: 'master' does not appear to be a git repository
fatal: 리모트 저장소에서 읽을 수 없습니다

올바른 접근 권한이 있는지, 그리고 저장소가 있는지
확인하십시오.
user01@ubuntu:~/다운로드/sprint-simple-git-workflow$ git push origin master
오브젝트 나열하는 중: 10, 완료.
오브젝트 개수 세는 중: 100% (10/10), 완료.
오브젝트 압축하는 중: 100% (4/4), 완료.
오브젝트 쓰는 중: 100% (6/6), 550 바이트 | 137.00 KiB/s, 완료.
Total 6 (delta 2), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (2/2), completed with 1 local object.
To github.com:Park-ChanKyu/sprint-simple-git-workflow.git
   6917ecc..d06e693  master -> master

Leave a Comment