ABOUT ME

  • [Git] 저장소생성 및 Token가져오기
    카테고리 없음 2024. 9. 16. 18:45

    저장소

    1) Local Repository

    - 사용자의 컴퓨터 저장소

    2) Remote Repository

    - 원격서버 저장소

     

    Git 저장소 생성

    1) Git init

    - 아직 버전관리를 하지않는 프로젝트 폴더를 Git저장소로 만들 수 있다.

    2) Git Clone

    - Remote 저장소를 Local에 복사하여 사용할 수 있다.

     

    적용순서>

    -  Git Clone을 하는 순간 Repository이름을 가지고 프로젝트 생성

    - 프로젝트 안에 Git init을 해준다

    - Remote 안에 있는 파일을 땡겨와 프로젝트 안에 넣어줌

    # Remote Repository URL
    https://github.com/<orizination>/<project_name>.git
    https://github.com/<user_name>/<project_name>.git
    git clone <remote_repository_url>
    # 적용예시
    git clone https://github.com/<orizination>/<project_name>.git

     

    Git Clone with Token

    Git Clone을 할떄 토큰을 넣어줘야한다

    why?

    Git에서 로컬 저장소(Local Repository)와 원격 저장소(Remote Repository)는 수시로 동기화(push/pull) 작업을 하지만,

    원격 저장소에서 클론(clone)을 할 때 인증 토큰을 입력하지 않으면, 로컬 저장소가 원격 저장소에 요청할 때마다 아이디와 비밀번호를 요구하는 권한 체크가 발생한다. 아이디는 컴퓨터에 저장할 수 있지만, 비밀번호는 저장할 수 없어 인증 토큰을 사용하는 것이 보안상 더 안전하다.

    git clone https://<token>@github.com/<orizination>/<project_name>.git

     

    토큰가져오는 방법

    1. Setting > Developer Setting

     

    2. Personal access tokens > Tokens(classic) > Generate new token

     

     

    3. classic 토큰으로 선택후

     

      토큰 관리를 위해 이름지정

      기간선택

      적용범위설정 - 아래는 Git 관련 권한 줌

     ④ Generate token

     

     

     

     4. clone

    git clone https://<token>@github.com/<orizination>/<project_name>.git

     

    5. ls -all 명령어로 .git파일이 있는지 확인하기.

     

     

    -> .git파일이 있으면  repository이다.

Designed by Tistory.