본문 바로가기

IT 이야기/Git, SourceTree, Slack

git shell 정리

Git Shell(terminal 정리)

A. Git 새 저장소 만들기

a-1. 새 저장소 만들기

1. git init  // 원하는 폴더에서 git init로 사전 준비

2. git remote add origin 원격 서버 주소   //  원격 서버 주소에 링크


B. 원격저장소에 내용 push & pull

b-1. 새 내용 업데이트 하기

> 1. git add 파일 이름 or git add *

> 2. git commit -m "설명 메시지"

> 3. git push origin master


b-2. git 원격저장소에 있는 내용 로컬에 합치기

> 1. git pull origin master

> 2. git merge origin master


C. 여러 디렉토리에서 특정 디렉토리만 pull하기

c-1. 주어진 디렉토리 계층에서 특정 디렉토리만 pull하고 싶을 때

((상황)) mainproject의 subdirectory인 Example2만 pull하고 싶은 상황

- mainProject        //root directory

- Example1        //sub directory

- Example2        //sub directory

(방법)

> 1. git init examGit // 어디에 저장할지, init으로 설정

> 2. cd examGit

> 3. git remote add -f origin [remote url]

> 4. git config core.sparseCheckout TRUE // .git/config에 해당 내용 추가

> 5. echo "mainProject/Example2">> .git/info/sparse-checkout

> 6. git pull origin master //원격저장소로부터 pull