본문 바로가기

Git

Git 레포지토리란?

Git Repository

저장소. 말 그대로 파일이나 폴더를 저장해 두는 곳.

 

로컬 Git 리포지토리는 자신의 컴퓨터(로컬 환경)의 작업 공간에 위치한 Git 리포지토리이다.

컴퓨터 하드 드라이브에 원하는 디렉토리로 이동해서 로컬 Git 리포지토리를 추가하면 해당 디렉토리의 파일 변화를 알아차린다.

반대로, Github에서 생성한 리포지토리는 원격(remote) Git 리포지토리라고 한다.

내 컴퓨터 상에는 없지만, 원격에 존재하는 리포지토리이다.


Local repository에 저장된 파일을 Remote repository로 옮겨 수정할수 있고 그 반대로도 가능하다.

 

먼저 remote repo와 local repo를 연결해줘야 한다.

: git remote add origin <가져올 remote repository 깃헙 URL> // Remote repo와 Local repo를 연결하는 방법

 

Remote repo에 있는 파일을 Local repo로 가져오고 싶다면?

Remote repository => Local repository

: git pull <remote name> <branch name> // remote repo에 저장한 내역을 remote repo에 옮기는 작업

 

 

Local repo에 있는 파일을 Remote repo에 적용하고 싶다면?

Local repository => Remote repository

: git add // 커밋할 파일을 staging area로 이동

: git commit -m "commit message"

: git push <remote name> <branch name> // local repo에 저장한 내역을 remote repo에 옮기는 작업