자바스크립트를 활성화 해주세요

d044 Git Submodule Error났습니다

 ·  ☕ 2 min read

블로그를 포스트했는데, 블로그 사이트가 갱신되지 않았습니다. 뭔가 빌드가 잘 못되었구나 싶어 초근에 한 작업을 생각해 보니, 테마를 submodule화 했는데 그것이 잘 못된 것 같았습니다.

현재 submodule 확인하기

단순히 다음의 명령으로 확인할 수 있습니다. 그런데, 결과가 에러를 나타냅니다.

PS C:\Users\usr0100023\blog> git submodule
 c7c514f79162757c2cb5c84220221bfd6239f5b0 projects/hugomodule (heads/master)
 290800d19a793d00808910cfaa3d9ec5eeff39e5 themes/hugo-theme-zzofatal: no submodule mapping found in .gitmodules for path 'themes/zzo'
 (heads/master)

원래 정상으로 나온다면 다음과 같이 나와야 합니다.

PS C:\Users\usr0100023\blog> git submodule
 c7c514f79162757c2cb5c84220221bfd6239f5b0 projects/hugomodule (heads/master)
 290800d19a793d00808910cfaa3d9ec5eeff39e5 themes/hugo-theme-zzo (heads/master)

submodule update 시도

혹시나 해서 submodule update를 시도해 봤습니다.

PS C:\Users\usr0100023\blog> git submodule update --init
fatal: No url found for submodule path 'themes/zzo' in .gitmodules

하지만 같은 에러메시지가 나오고 있었습니다.

stage되어 있는 파일을 확인

우선 stage되어 있는 파일들을 확인해 보았습니다.

PS C:\Users\usr0100023\blog> git ls-files --stage | grep 160000
160000 c7c514f79162757c2cb5c84220221bfd6239f5b0 0       projects/hugomodule
160000 290800d19a793d00808910cfaa3d9ec5eeff39e5 0       themes/hugo-theme-zzo
160000 4f3acae64031126e382af7381efa93fa7fe7bc6e 0       themes/zzo

themes/zzo가 stage되어 있는데, 그 내용이 없나봅니다. 원래 zzo라는 테마디렉토리는 하나만 있으면 되는데, 두 개가 등록되어 있는 것도 잘못된 부분입니다.

불필요한 디렉토리를 삭제

불필요한 themes/zzo를 stage에서 삭제하도록 하였습니다.

PS C:\Users\usr0100023\blog> git rm --cached themes/zzo
rm 'themes/zzo'

git submodule 확인 결과 이상이 없어 commit하였습니다.

전체 과정

문제를 발견하고 해결한 전체 과정은 다음과 같습니다.

PS C:\Windows\system32> cd $env:USERPROFILE
PS C:\Users\usr0100023> cd blog
PS C:\Users\usr0100023\blog> git submodule
 c7c514f79162757c2cb5c84220221bfd6239f5b0 projects/hugomodule (heads/master)
 290800d19a793d00808910cfaa3d9ec5eeff39e5 themes/hugo-theme-zzofatal: no submodule mapping found in .gitmodules for path 'themes/zzo'
 (heads/master)
PS C:\Users\usr0100023\blog> git ls-files --stage | grep 160000
160000 c7c514f79162757c2cb5c84220221bfd6239f5b0 0       projects/hugomodule
160000 290800d19a793d00808910cfaa3d9ec5eeff39e5 0       themes/hugo-theme-zzo
160000 4f3acae64031126e382af7381efa93fa7fe7bc6e 0       themes/zzo
PS C:\Users\usr0100023\blog> git submodule update --init
fatal: No url found for submodule path 'themes/zzo' in .gitmodules
PS C:\Users\usr0100023\blog> git rm --cached themes/zzo
rm 'themes/zzo'
PS C:\Users\usr0100023\blog> git submodule update --init
PS C:\Users\usr0100023\blog> git status
On branch master
Your branch is up to date with 'origin/master'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        deleted:    themes/zzo

PS C:\Users\usr0100023\blog> git add -A
PS C:\Users\usr0100023\blog> git commit -m "20210124 1505"
[master 66cfed2] 20210124 1505
 1 file changed, 1 deletion(-)
 delete mode 160000 themes/zzo
PS C:\Users\usr0100023\blog> git push
warning: redirecting to https://github.com/crowdy/blog.git/
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 4 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 293 bytes | 293.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To http://github.com/crowdy/blog.git
   3333283..66cfed2  master -> master
PS C:\Users\usr0100023\blog> git ls-files --stage | grep 160000
160000 c7c514f79162757c2cb5c84220221bfd6239f5b0 0       projects/hugomodule
160000 290800d19a793d00808910cfaa3d9ec5eeff39e5 0       themes/hugo-theme-zzo
PS C:\Users\usr0100023\blog> git add -A
PS C:\Users\usr0100023\blog> git commit -m "20210124 1506"
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean
PS C:\Users\usr0100023\blog> git push
warning: redirecting to https://github.com/crowdy/blog.git/
Everything up-to-date
PS C:\Users\usr0100023\blog> git submodule
 c7c514f79162757c2cb5c84220221bfd6239f5b0 projects/hugomodule (heads/master)
 290800d19a793d00808910cfaa3d9ec5eeff39e5 themes/hugo-theme-zzo (heads/master)
PS C:\Users\usr0100023\blog> 

Ref

공유하기

tkim
글쓴이
tkim
Software Engineer