본문 바로가기

Unity/Github 연동

Unity-Github 연동: 파일이 너무 크고 아름다워요

참고: https://hereishyun.tistory.com/29

 

Github 협업 중 유니티 프로젝트 업로드 안 됨 해결 (100mb 용량 초과 문제, .gitignore)

------- 2024년 덧붙임 ------- 본문 요약: .gitignore가 잘 안 되어서 그렇고, .gitignore 파일을 유니티 프로젝트 폴더 안에 넣어주면 됨. 문제 발생의 핵심: 깃허브 레포지토리 클론한 폴더 != 유니티 프로

hereishyun.tistory.com

클론한 repository에 유니티 프로젝트 파일을 옮길 시 가끔 파일이 너무 크다며 안내 문구가 뜰 때가 있다. 

분명 유니티 프로젝트 파일을 깃허브에 연동하기 위해 우리는 .gitignore 파일까지 만들었는데 왜 이렇게 된 걸까?

 

우선 .gitignore 주석을 보면

# This .gitignore file should be placed at the root of your Unity project directory
#
# Get latest from https://github.com/github/gitignore/blob/main/Unity.gitignore
#
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
/[Ll]ogs/
/[Uu]ser[Ss]ettings/

...

 

# This .gitignore file should be placed at the root of your Unity project directory

.gitignore 파일은 유니티 프로젝트 경로 안에 포함되어야 한다는 것이다.

 

만약 위와 같은 경고가 떴다면 이렇게 .gitignore 파일이 유니티 프로젝트 외부에 있을 가능성이 크다. 왜냐하면 유니티에서 프로젝트를 생성할 때 Asset, Library 등의 파일을 한 번 더 묶게 되어 '프로젝트 이름'의 폴더가 제일 상위에 있기 때문이다. 그러니 .gitignore의 파일과 유니티 프로젝트 파일이 별개로 존재하여 동작하지 않는 것이다.


그래서 해결법이 뭐임?

 

1. 유니티 프로젝트 최상위 폴더를 삭제하고 내부에 있는 Asset, Library 등의 파일을 끄집어낸다.

하지만 이 방법은 딱히... 반기지는 않을 것이다.

 

2. .gitignore을 수정한다.

# This .gitignore file should be placed at the root of your Unity project directory
#
# Get latest from https://github.com/github/gitignore/blob/main/Unity.gitignore
#
**/[Ll]ibrary/
**/[Tt]emp/
**/[Oo]bj/
**/[Bb]uild/
**/[Bb]uilds/
**/[Ll]ogs/
**/[Uu]ser[Ss]ettings/

...

이렇게 디렉토리 앞에 **를 붙이면 ** 뒤의 모든 경로를 참조할 수 있다. 그러니 유니티 프로젝트의 대표 용량 도둑인 Library 디렉토리 파일을 무시할 수 있는 것이다.

 

확인하니 .gitignore 전용 문법이 존재한다. 배우고 더 강해지자.

https://git-scm.com/docs/gitignore

 

Git - gitignore Documentation

The optional configuration variable core.excludesFile indicates a path to a file containing patterns of file names to exclude, similar to $GIT_DIR/info/exclude. Patterns in the exclude file are used in addition to those in $GIT_DIR/info/exclude.

git-scm.com