git을 쓰면서 발생했던 오류들에 대해 정리해보았다.

오류 1

오류:

warning: LF will be replaced by CRLF in [파일 이름].
The file will have its original line endings in your working directory

해결:

# Windows, DOS 명령어
$ git config [--global] core.autocrlf true

# Linux, MAC 명령어
$ git config [--global] core.autocrlf input

시스템 전체 적용을 하고 싶다면 –global 옵션을 주고, 해당 프로젝트에만 적용하고 싶다면 옵션을 빼주면 된다.

설명:

이는 줄바꿈 문자열이 다르기 때문에 나타나는 오류이다.

줄바꿈 문자열은 각각 아래와 같다.

LF : “\n”

CR : “\r”

CRLF : “\r\n”

오류 2

오류:

git-lfs filter-process: git-lfs: command not found
fatal: the remote end hung up unexpectedly

해결:

https://git-lfs.github.com/

에 들어가서 git-lfs 를 설치해주고, cmd 창을 껐다 다시 키면 된다.

설명:

lfs는 Large File Storage 의 약자로 큰 용량의 파일을 다룰 때 사용되는 프로그램이다.

용량이 큰 파일을 git에 올리고자 할 때 위의 오류가 뜰 수 있다.

이 문제를 해결할 시, 오류 3 문제가 발생할 수 있다.

오류 3

오류:

LFS upload failed:cts:   0% (0/7), 0 B | 0 B/s
  (missing) data/precedentAppearance.csv (a77cbf76fa5dbe700485b604354eb13aab22ccf720ea87efd8aa29b25a840558)
  (missing) data/questionWord.csv (54c8fb5376fa463b0addddbcdc18048878e62495bb338af43c10414e0455c0af)
  (missing) data/answerRatio.csv (b6919586f45296b8d682be4e9de7d1c0e059374ce43701c06a7c713c60b72f71)
  (missing) data/likelihoodTable.csv (4e072b6906c0f5b13233070e971c783e21012ee0910f3105cfb29a9fe472680b)
  (missing) data/word2Vec (b8bd5db3e37c479b94fc2fe2548cd76f49f1d4b006b369d991ccf8d6271a93df)
  (missing) data/precedentWord.csv (3e4dffb7930002b9c280fa1a35095502a20f40251d0dacfe17dffc19dd3d5acf)
  (missing) data/precedentList.csv (e6263bf500417c8cccbf6340f9dbb9c4bea0d040928b8bc3da2b283ffa6d72bc)
Uploading LFS objects:   0% (0/7), 0 B | 0 B/s, done.
hint: Your push was rejected due to missing or corrupt local objects.
hint: You can disable this check with: 'git config lfs.allowincompletepush true'
error: failed to push some refs to 'https://github.com/lys7aves/LawAkinator.git'

설명:

git에서 대용량 파일을 다운 받을 경우, 파일을 직접 다운 받지 않고 파일에 대한 정보만 다운 받아지는 경우가 생긴다. (실제로 파일의 크기를 보면 다 1KB인 것을 볼 수 있다.) 이 상태에서 다른 repository에 파일을 올리려고 하면 파일 크기가 맞지 않아 위와 같은 오류가 뜨게 된다.

따라서 온전한 파일을 다시 다운 받은 후 올려야 한다. 이는 아래와 같이 git lfs install을 한 후, git clone을 통해 파일을 다시 다운 받을 수 있다.

해결:

# 파일 다시 다운 받기
$ git lfs install
$ git clone [github 경로]

이후, 오류가 발생했던 파일들을 보면 원본 그대로 파일이 다운 받아진 것을 확인할 수 있다.

이제, 다시 해당 파일들을 lfs로 git에 올려주면 된다.

오류 4

오류:

error: src refspec main does not match any
error: failed to push some refs to 'https://github.com/lys7aves/LawAkinator.git'

해결:

$ git pull [remote] [branch]
# git pull origin main
$ git commit -m "[message]"
$ git push origin main

설명:

기존 repository에 push를 할 경우, pull을 먼저 해주어야 하는데 그렇지 않고, push를 하려고 할 때, 뜰 수 있다.

따라서 pull 을 먼저 해주고 다시 commit을 한 후, push를 해줌으로써 문제를 해결할 수 있다.