Skip to content
Hyungoo Kang edited this page May 16, 2022 · 18 revisions

How to share problems to solve

Create new issue as follows

Title

${Algorithm Site + problem.no}
  • Alogrithm Sites
    • Baekjoon Online Judge(BOJ)
    • Programmers(P)
    • SW Expert Academy(SEA)
    • LeetCode(LC)
  • e.g. BOJ2480, LC1204, P1235645, SEA1044

Content

### Link
${problem.link}

Label

  • Select todo label

How to submit

Prerequisite

Fork

  • upstream을 fork하여 내 저장소에 추가한다.

Clone

git clone https://github.com/${github.username}/algorithm-study.git
  • origin을 local로 가져온다.
git remote -v
  • 연결 상태 확인
  • origin 및 upstream이 잘 설정되어 있는지 확인
git remote add upstream https://github.com/oognuyh/algorithm-study.git
  • upstream 추가
git pull upstream master
  • upstream의 master branch를 가져와서 병합
  • pull 대신 fetch & merge 명령어 사용 가능

Push

git checkout -b ${issue.name}
  • origin 저장소에 ${issue.name}이라는 branch를 생성하고 master에서 switch한다.
git add ./${issue.name}/${github.username}.${file.extension}
git commit -m "solve ${issue.name} (#${issue.no})"
git push origin ${issue.name}
  • 파일명은 ${github.username}.${file.extension}으로 할 것
  • 파일은 ${issue.name} 폴더 아래에 위치할 것(e.g. BOJ2480/oognuyh.kt)
  • 코드 내 package 경로는 프로젝트 내 경로와 동일 (e.g. package BOJ2480;)
  • java의 경우 클래스 명을 ${github.username}으로 변경할 것(e.g. class ${github.username} { ... ))
  • ${issue.name} 문제를 풀고 커밋 양식에 맞게 작성 후 origin의 ${issue.name} branch로 push
  • 해당 파일만 push할 것

Pull Request

git pull upstream master
  • Pull Request를 생성하기 전에 최신 상태로 만들어 줌
  • Github를 통해 origin의 ${issue.name} branch를 Pull 해달라고 upstream에 요청을 보낸다.
  • PR 생성 시 Reviewers 선택할 것

Code Review

  • 코드 리뷰 후 승인이 되면 upstream의 master branch에 병합됨
  • 코드 리뷰 후 파일 수정이 필요한 경우
git pull origin ${issue.name}
  • PR 시 Github actions을 통해 formatting을 하기 때문에 다시 가져옴
git add ${changedFile(s)}
  • 수정이 끝나면 수정된 파일 스테이징
git commit -m "fix ${issue.name} (#${issue.no})
git push origin ${issue.name}
  • 커밋 후 PR을 요청했던 branch에 push하면 알아서 반영됨

  • 만약, 오타 등 실수로 이전 커밋에 덮어씌우고 싶은 경우는 아래의 명령어를 따름

    git commit --amend
    git push -f origin ${issue.name}
    • 이전 커밋이 push가 되어있기 때문에 강제로 branch에 push함
    • push 후 에디터가 나오는데 ESC -> : -> wq! 를 순서대로 입력하면 해당 커밋 메세지로 저장되고 진행됨

Merge

  • 병합 후 git pull upstream master를 통해 최신 데이터 유지하고 다른 문제 풀이
Clone this wiki locally