[Troubleshooting] Git 파일 Permission 설정

배배·2024년 4월 27일

Git

목록 보기
1/1

📌 Git 파일 Permission 설정하기



❓ 문제

  • 워크플로 배치 실행시 Gitlab 레퍼지토리의 .sh 파일 실행 결과 Permission denied 에러 발생



🔍 원인


1. 현재 git 파일 Permission 확인
$ git ls-files --stage
100644 a003xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 0       hash.sh
  • Permission 644
    • 루트 사용자 권한 : 읽기, 쓰기
    • 일반 사용자 권한 : 읽기
    • 그룹 권한 : 읽기
  • 파일 실행 권한이 없음을 확인



✅ 해결


1. 파일모드 변경 추적 설정 적용
$ git config core.fileMode true

2. 파일 Permission update
$ git update-index --chmod=+x ./hash.sh

3. 현재 git 파일 Permission 확인
$ git ls-files --stage
100755 a003xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 0       hash.sh

4. commit
$ git commit -m "update permission"

5. push
$ git push arigin main
  • Permission 755
    • 루트 사용자 권한 - 읽기, 쓰기, 실행
    • 일반 사용자 권한 - 읽기, 실행
    • 그룹 - 읽기, 실행
  • 파일 실행 권한을 부여하여 해결
profile
데이터 엔지니어

0개의 댓글