본문 바로가기

git

[git] 깃허브 (git init, remote, clone, pull)

깃허브에 프로젝트 올리기

 

(스테이지, 커밋 영역 그림파일 첨부 예정)

터미널에서 깃허브와 연결하려는 폴더(my_git)로 경로 설정

cd "프로젝트 경로"

ex.
cd my_git

 

 

 

 

 

 

 

 

 

 

 

 

 

 

스테이지 영역으로 옮기는 명령어

git add .

 

 

스테이지에 올라가 있는 파일 목록 확인하는 명령어

git status

 

 

스테이지에서 커밋으로 올리는 명령어

git commit -m "업데이트 내용 적는 부분" // 따옴표 포함

ex.
git commit -m "2022년 2월 21일"

 

 

repository 연결

git remote add origin "깃허브 repository 주소"

ex.
git remote add origin https://github.com/myAccount/stree.git

 

 

깃허브에 push

git push origin master

 

 


깃허브에 올라가 있는 프로젝트 다른 컴퓨터에서 받기 (clone, pull)

 

해당 컴퓨터에 프로젝트가 존재하지 않는 경우

 

프로젝트 경로 설정

cd "프로젝트 받을 경로"

ex.
cd my_git2

 

 

복제할 repository 주소

git clone "repository 주소"

ex.
git clone https://github.com/myAccount/stree.git .

 

 

clone의 경우 .git 파일이 같이 받아지므로 자동으로 repository와 연결됨. (git init 할 필요 없음!)

 


이미 clone이 존재하는 경우

 

git pull "repository 주소"

ex.
git pull https://github.com/myAccount/clonetest.git