728x90
반응형

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
  • gpg key 생성
gpg --gen-key
  • name, e-mail, 암호 등을 설정해 주면 된다.
  1. github 저장소를 만든다.
https://github.com/account/repo
  1. git 저장소 clone 한다.
git clone https://github.com/account/repo
  1. 저장소를 깃크립트 용으로 초기화한다.
cd repo
git-crypt init
  • .git/git-crypt/ 경로가 생기고, 경로 밑에 관련 파일들이 자동 생성된다.
  1. 저장소 최상위 경로에 .gitattributes 파일을 생성한다.
vim .gitattributes
  1. .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
  1. 깃어트리뷰트 설정 파일을 추가한다.
git add .gitattributes
  1. commit 및 push 를 수행한다.
git commit * -m "testing"
git push
  1. 다음부터 commit 및 push 수행 시, 파일이 암호화되어 github 에 저장된다. (로컬에 받은 파일은 암호화되지 않고, github에 올리는 파일만 암호화 됨)
  • 수정
vim hello.txt
  • 저장소 올리기
git commit * -m "testing"
git push

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

  1. git 저장소를 clone 한다. git clone https://저장소.git
  2. 기존 저장소의 .git/git-crypt/* 를 현재 경로의 .git/ 경로 아래로 복사한다.
  3. 다음과 같은 방식으로 키 값을 설정한다. git-crypt init .git/git-crypt/
728x90
반응형

+ Recent posts