반응형

git-crypt 사용법


1. git-crypt 설치

  • Linux (Ubuntu)
       sudo apt install git-crypt
       sudo apt install gnupg
    

  • Windows (scoop 으로 설치)
       scoop install git-crypt
       scoop install gnupg
    

1.1 gpg key 생성

  • bash

      gpg --gen-key
    
  • name, e-mail, 암호 등을 설정해 주면 된다.



2. github 저장소 생성

  • example repo : https://github.com/account/repo



3. git 저장소 로컬 복사(clone)

  • bash

     git clone https://github.com/account/repo
    


4. 저장소를 깃크립트 용으로 초기화

  • bash

      cd repo
      git-crypt init
    
  • .git/git-crypt/ 경로가 생기고, 경로 밑에 관련 파일들이 자동 생성된다.



5. 저장소 최상위 경로에 .gitattributes 파일 생성

  • bash

      vim .gitattributes
    


6. .gitattributes 파일 설정

  • .gitattributes

      # 암호화 될 파일들 설정
      hello.txt filter=git-crypt diff=git-crypt
      code/world.cpp filter=git-crypt diff=git-crypt
      
      # 암호화 되지 않을 파일들 설정
      # .gitattributes 파일은 암호화 되지 않도록 설정
      .gitattributes !filter !diff
      README.md !filter !diff
    


7. 깃어트리뷰트 설정 파일 추가

  • bash

      git add .gitattributes
    


8. 리모트 저장소에 입력 (commitpush 수행)

  • bash

      git commit * -m "testing"
      git push
    


9. 로컬 파일 수정 및 업로드 작업

  • 다음부터 commitpush 수행 시, 파일이 암호화되어 github 에 저장된다.

    • 로컬 에 받은 파일은 암호화되지 않고 , github에 올리는 파일만 암호화 됨.
  • 파일 수정

      vim hello.txt
    
  • 저장소 올리기

      git commit * -m "testing"
      git push
    


10. 다른 저장소에서 git-crypt 사용하는 방법

  • (1) git 저장소를 clone 한다.

    • git clone https://저장소.git
  • (2) 기존 저장소의 .git/git-crypt/* 를 현재 경로의 .git/ 경로 아래로 복사한다.

  • (3) 다음과 같은 방식으로 키 값을 설정한다.

    • git-crypt init .git/git-crypt/



  • 도움이 되셨으면 하단의 ❤️ 공감 버튼 부탁 드립니다. 감사합니다! 😄
  • 일부 모바일 환경에서는 ❤️ 버튼이 보이지 않습니다.

728x90
반응형

+ Recent posts