Invalid Error라는 문구가 뜨며 해당 에러를 마주한 사람들은 매우 당혹할 것이다.
왜냐하면 내가 그랬으니까..
최근 스터디를 진행하며 스터디원들에게 주차별 과제를 PR로 받고 있었고 그를 리더인 내가 확인하고 Merge하는 방식으로 스터디를 진행하고 있었다. 하지만 파일명을 제대로 확인하지 못하고 Merge를 한후 git pull을 origin/main으로 시도하자 다음과 같은 에러를 만나게 되었다.
error: invalid path 'Javascript/week3/Siby1lA/?IIFE.md'
해당 에러 문구를 보면 파일의 위치를 찾을 수 없는 것 같은데 이게 무엇일까?
우선 Javascript라는 패키지안에 week3-Siby1lA로 이어지는 패키지 구조이기에 혹시라도 Main에 해당 패키지 구조가 생성되지 않는데 찾는 것일까라는 멍청한 생각이었다. 그렇다면 pull을 시도할 때 애초에 해당경로를 찾지 않을테니까
"그렇다면 뭐가문제일까?"라고 혼자 곰곰히 되새기던 중 문득 Junit공부할 때 한국어나 특수문자가 경로상에 잘못들어갈 경우 문자가 Encoding되지 않고 특수문자처럼 ?또는 깨진 문자를 보았던 것이 생각났다.
"그렇다면 혹시 파일 이름이 문제인가?"라는 생각을 가지고 파일네임을 확인해보니 IIFE.md 였다.
저런 문자가 왜 들어가는 것인가 하고 구글링을 하다보니 답을 알 수 있었다.
Window 운영체제의 파일 시스템(NTFS)과 MAC OS(MAC OS 표준 파일시스템)에서 관리하는 파일의 특징이 다르다 보니 파일명의 제한도 달라서 생기는 오류라고 적혀있었다.
에러 경로를 살펴보면 '?'가 들어가 있는 모습을 볼 수 있는데 Mac을 사용하는 팀원이 파일명에 특수문자를 넣어 Commit한 것이었다. 물론 Mac을 사용하는 팀원 입장에서는 문제없이 사용가능했을 것이나 나는 이 사실을 모른채로 PR을 Merge한 후 pull을 시도하자 윈도우를 사용하는 나는 에러를 만나게 된 것이다.
(Main Branch에 Merge할 때는 PR을 항상 꼼꼼히 확인하자...😂😂)
해당 문제를 해결하는 방법은 다행히 존재하였고, 무려 두가지가 되니 이를 알아보자
해결방안1
PR을 날린 팀원이 파일명을 수정한 후 새로이 PR을 날려 이를 Merge하거나 본인이 직접 Github에서 삭제 또는 수정하는 방법이다. 이는 간단히 Main Branch 하나만을 이용하거나 그 파일의 중요도가 낮을 경우 추천하는 방법이다. (자신이 Maintainer라면 바로 수정하자)
해결방안 2
필자는 해당 방법을 추천한다. 협업 시에도 유용하게 사용할 수 있는 방법이라고 생각한다.
1.TestBranch를 만든다.
# 단, checkout 할때의 기준 브랜치는 master여야 한다.
git checkout -b "test"
2. 문제가 되는 문자열을 삭제한다.(?,*,\ 외의 특수 문자들)
3. 수정 내용 git에 반영한 후 push하여 동기화한다.
# -a : commit all changed files
# 단, -a option은 이미 기존에 add되어서 tracked 상태인 파일을 수정했을 경우에만 제대로 반영이 된다.
git commit -am "fix: file name to resolve bug"
git push origin test
4. 해당 내용을 PR하고 origin/master에 merge하기
5. 문제가 되었던 팀원의 local storage에 다시 pull 해오기
# 혹은 fetch후 rebase 해주셔도 됩니다. fetch+merge = pull
git pull
혹시라도! 이렇게 진행했는데도, pull이 안된다면 아래 Git을 참고해보자
https://github.com/endless-sky/endless-sky/issues/793
'GitHub' 카테고리의 다른 글
본인의 깃허브 꾸미기 (README.md 꾸미기) (0) | 2022.03.14 |
---|