Git - Fork 사용한 Git 협업

  • 이번에는 Fork 기능을 사용하여 Git으로 협업하는 방법에 대해 알아볼 것이다.

Fork 사용하여 Git 협업하기

1. organization 생성

  • 우측 상단 ‘New organization’ 클릭
    Screenshot from 2019-07-21 01-16-54

2. create an organization 진행

  • Organization name 입력 및 organization 소속 선택
    Screenshot from 2019-07-21 01-18-30
  • 비용 상세 정보 수신할 이메일 주소 입력
    Screenshot from 2019-07-21 01-18-33

  • 초대할 유저아이디 혹은 이름 혹은 이메일 주소 입력하여 invite 진행
    Screenshot from 2019-07-21 01-19-33

  • organiztion 목적 및 예상 소요기간, 팀원 인원 선택
    Screenshot from 2019-07-21 01-20-21

3. organization 생성 완료 및 repository 생성 진행

  • organization 생성 완료 확인
    Screenshot from 2019-07-21 01-20-33

  • 생성한 organization에서 new repository 생성
    Screenshot from 2019-07-21 01-20-49

  • 생성한 repository 경로 복사
    Screenshot from 2019-07-21 01-21-01

4. git 진행할 프로젝트에서 관련 명령어 실행

  • git 초기화

    1
    $ git init
  • git flow 초기화

    1
    $ git flow init
  • gitignore 파일 생성

    1
    $ git touch .gitignore
  • 앞서 복사한 organization에 생성된 repository 경로(중앙 저장소의 repository 경로)를 upstream 별칭으로 설정

    1
    $ git remote add upstream https://github.com/organiztion-jonus/jonus_project.git
  • gitignore.io 사이트에서 git에 올리지 않을 파일명 업로드
    Screenshot from 2019-07-21 01-26-34

  • gitignore.io 사이트에서 특정 파일명 입력 후 결과 내용을 .gitignore 파일에 붙여넣기
    Screenshot from 2019-07-21 01-27-41
    Screenshot from 2019-07-21 01-28-34

  • 중앙 원격저장소(organization-jonus/jonus_project)에서 우측 상단 Fork 클릭하여 본인 github로 fork 진행
    Screenshot from 2019-07-21 01-32-27

  • 본인 github 저장소로 fork된 repository 경로 복사
    Screenshot from 2019-07-21 01-32-41

  • git 업로드할 프로젝트 위치에서 본인 github에 있는 fork된 repo 주소를 origin 별칭으로 설정

    1
    $ git remote add origin https://github.com/chohyeonkeun/jonus_project.git
  • 각각의 repository 경로가 upstream, origin으로 제대로 설정되어있는지 확인

    1
    $ git remote -v

    Screenshot from 2019-07-21 01-33-06

5. branch 생성하여 본인 저장소의 repository(develop branch)로 git push 진행

  • branch 생성하여 코드 작성

    1
    $ git flow feature start test
  • 코드 작성 후, 본인 저장소의 develop branch로 push 진행

    1
    2
    3
    $ git add -A .
    $ git commit -m 'test'
    $ git push origin feature/test

6. 본인 github 저장소에서 pull request 진행

  • jonus_project repository 중앙 부분 ‘New pull request’ 클릭
    Screenshot from 2019-07-21 02-09-48

  • ‘Create pull request’ 클릭
    Screenshot from 2019-07-21 02-09-54

  • Open a pull request 진행 (pull request에 대한 내용 입력)
    Screenshot from 2019-07-21 02-10-00
    Screenshot from 2019-07-21 02-10-11

  • 중앙 저장소 repository에서 pull request 요청 확인
    Screenshot from 2019-07-21 02-10-33

  • ‘Merge pull request’ 클릭
    Screenshot from 2019-07-21 02-10-38

  • ‘Confirm merge’ 클릭
    Screenshot from 2019-07-21 02-10-42

  • pull request merge 성공
    Screenshot from 2019-07-21 02-10-49

7. push 및 pull request 완료한 branch merge 및 삭제

  • develop branch로 checkout 이후, flow feature finish 명령어 실행
    1
    2
    $ git checkout develop
    $ git flow feature finish test

8. 다른 팀원의 pull request 이후, 중앙 저장소 repository에서 업데이트된 코드 pull 진행

  • pull로 받아오고 싶은 로컬 branch에서 git pull 진행

    1
    $ git pull upstream develop
  • ‘fatal: refusing to merge unrelated histories’ error 발생할 경우 아래 명령어 실행

    1
    $ git pull origin develop --allow-unrelated-histories

9. 5~8번 프로세스 반복하여 push 및 pull 진행