본문 바로가기
CI&CD/Git

[Git] git push 하지 않고 작업 사항을 공유하는 방법

by TSpoons 2024. 8. 18.

목적은 이렇다. 그냥 git push 하지 않아서 드러내지 않고, 로컬이 아닌 내 작업을 집에서도 할 수 있도록 코드를 가져오려고 했지만, 방법은 딱히 없다. 

 

새로운  사적인 repo를 만드는 방법이다! 그떄 유용하게 쓰이는 포장방법(?!)을 소개한다.

 

1. git bundle 이용

 

- 배포

- 지금까지 작업한 모든 것들을  번들 파일로 만듦

git bundle create my_repo.bundle --all

 

- 특정 브랜치만 포함할 수도 있음

git bundle create my_repo.bundle [branch name]

 

 

- 사용

 

- 어느 branch를 가리키고 있는 지 확인하고, 

git bundle list-heads my_repo.bundle

 

- 번들 파일을 받고 새 디렉토리에서 복원

git clone my_repo.bundle -b main my_local_repo

 

 

- 기존 저장소에서 복원

git fetch my_repo.bundle main
git checkout -b new_branch FETCH_HEAD

 

2. git format-patch, git am 이용

 

- 배포 

- origin/main 브랜치 이후 모든 커밋을 patch 파일로 만듦

git format-patch origin/main --stdout > changes.patch

 

 

- 사용

git am < changes.patch

 

3. git send-email을 사용한 이메일 전송

 

- 그냥 냅다 이메일 보내기! 

-- 코드리뷰 요청용

git send-email --to=[example@example.com] --subject="Patch Submission" origin/main

 

(git send-email 설정 확인)

git send-email 명령어를 사용하기 전에 Git의 이메일 설정을 올바르게 구성해야 합니다. SMTP 서버와 관련된 설정

 

이메일 설정:사용자의 SMTP 서버와 인증 정보를 설정

git config --global sendemail.smtpserver smtp.example.com
git config --global sendemail.smtpuser yourusername
git config --global sendemail.smtppass yourpassword