Git - Troubleshooting

choko's avatar
Jun 29, 2024
Git - Troubleshooting
 

깃 계정 여러개 설정하기

  • ssh 인증을 할 때, 따로 설정을 해 주지 않으면 ~/.ssh/id_rsa 로 인증을 진행한다.
  • 여러 계정을 설정하고 싶으면 ssh config의 host 등록을 하고 IdentityFile 경로를 맞춰 주어야 한다.
 
  • 개인계정, 회사계정이 있을 경우
  1. ssh-key 생성
    1. //1 개인계정 ssh-keygen -t rsa "개인계정@email" -f "id_rsa_tom" //2 회사계정 ssh-keygen -t rsa "회사계정@email" -f "id_rsa_company"
       
  1. ssh-agent에 ssh-key 추가
eval "$(ssh-agent -s)" ssh-add ~/.ssh/id_rsa_ddr4869 ssh-add ~/.ssh/id_rsa_company
3. github에 계정별로 public key 추가
 
 
  1. ~/.ssh/config 설정
Host github.com-tom HostName github.com User tom IdentityFile ~/.ssh/id_rsa_tom Host github.com-company HostName github.com User company IdentityFile ~/.ssh/id_rsa_company
 
  1. ssh 연결 테스트
ssh -T git@github.com-tom // Hi tom! You've successfully authenticated, but GitHub does not provide shell access
 
  1. git clone
!! 클론 시 다음과 같이 ssh 경로 수정 필요 git@github.com-tom:tom/gof.git
 

깃 새 레포에 커밋하기

  1. 기존 프로젝트에서
    1. git init
  1. 새 레포 생성 후. git remote
    1. git remote add origin git@{{새 레포 ssh}}
  1. 원격 브런치로 commit, push
    1. git add . git commit -m '첫번째 커밋' git push origin main
 
 

깃 Pull Request Approve 설정하기

  1. PR Approve를 설정할 Repo의 Settings→Branches→Add branch ruleset
    1. notion image
 
  1. Ruleset 세팅
    1. notion image
      • Ruleset Name → 해당 ruleSet의 이름
      • Enforcement status → Ruleset 활성화
      • Bypass List → Ruleset을 무시할 수 있는 admin같은 허용된 개체들 지정
      • Target branches → Ruleset의 대상 브런치 지정
       
      notion image
      • Rules들 중에 원하는 제약사항을 적용시킬 수 있다.
  1. Git Actiondmfh PR 테스트
      • 권한이 없는 계정으로 로그인해서, PR을 날려보자.
      notion image
      • PR이 도착했다. Git Action으로 올바른 PR인지 검증해보자.
        • PR을 수신한 admin → run all jobs로 Git action 검증
        • notion image
        • PR을 보낸 유저
        • notion image
        • PR이 git action을 통과하지 못한경우, 자동으로 실패
          • notion image
    1. 최종 PR Approve
        • admin은 Merge pull request를 눌러 PR을 최종 승인한다.
        notion image
         
Share article

Tom의 TIL 정리방