툴/깃허브

[GitHub] LeetCode 깃허브 하위폴더 연동

believekim 2025. 6. 6. 15:43

 

LeetCode를 깃허브에 연동시켰더니 레포지토리에만 가능하였다. 
그래서 기존 알고리즘 레포지토리가 있었기에 하위폴더에 연동시키는 방법을 알아보고자 한다.

 

 

 

시스템 환경

IDE IntelliJ IDEA
Browser Chrome 
Chrome 확장프로그램 LeetHub v3

 

 

1. 아래 깃허브에서 fork를 해서 내 래포지토리로 가져온다.

https://github.com/raphaelheinz/LeetHub-3.0

 

GitHub - raphaelheinz/LeetHub-3.0: Automatically push your LeetCode solutions to your GitHub repository

Automatically push your LeetCode solutions to your GitHub repository - raphaelheinz/LeetHub-3.0

github.com

 


 

 

2. 레포지토리를 clone받고 폴더를 연다. 

  • $ git clone <LeetCode를 클론 받아온 깃허브 주소>
  • 그 후에 LeetHub-3.0/src/js/leetcode.js파일을 연다.


 

 

3. 88번째 줄 contents뒤에 하위폴더의 경로를 넣는다.

// 필자는 Algorithm이라는 레포지토리 하위폴더로 /problem/src/leetcode로 넣어서 아래와 같이 바뀌었다.

function constructGitHubPath(hook, basePath, difficulty, problem, filename, useDifficultyFolder) {
  const path = useDifficultyFolder
    ? `${basePath}/${difficulty}/${problem}/${filename}`
    : `${problem}/${filename}`;
  return `https://api.github.com/repos/${hook}/contents/problem/src/leetcode/${path}`;
}

 

 

4. 크롬 확장프로그램에 들어가서 개발자모드를 키고 수정한 어플리케이션을 적용시킨다.


 

5. 확장프로그램을 실행시켜서 원하는 레포지토리를 연동한다.

 


 

6. 결과확인

  • 문제를 풀고 푸쉬해보면

 

  • 하위폴더로 생성되는 것을 볼 수 있다.


 

 

번호별이나 난이도 별로 묶을 수 있는 기능이 있으면 좋을꺼 같은데 나중에 찾아봐야겠다.