본문 바로가기

기록/새싹x코딩온

[새싹x코딩온] 웹 퍼블리싱 과정 1주차 - 1 | Git

1. Git 설치

https://git-scm.com/

 

Git

 

git-scm.com

git 홈페이지에서 다운로드를 하면 된다.

 

2. GitHub 회원가입

https://github.com/

 

GitHub: Let’s build from here

GitHub is where over 100 million developers shape the future of software, together. Contribute to the open source community, manage your Git repositories, review code like a pro, track bugs and fea...

github.com

github 홈페이지에서 회원가입을 한다.

여기서 만든 프로필 이름과 이메일 주소는 git에 연결할 때 적어야 하니 외워두자

 

3.  Git Bash로 GitHub 연결하기

Git Bash에

cd Desktop  #cd 안에 있는 Desktop폴더로 이동
mkdir github  #github폴더 생성
cd github  #cd 안에 있는 github폴더로 이동
git config --global init.defaultBranch main
git config --global user.name "프로필 이름"
git config --global user.email "이메일 주소"
git config --global --list  #프로필 이름과 이메일 주소를 보여준다

이렇게 입력한 후

GitHub에서 새로운 repository를 생성하고 주소를 복사한다.

다시 Git Bash로 돌아와서 복사한 주소를 우클릭 paste로 붙여넣으면

git clone (복사한 주소)  #생성한 repository를 가져온다
cd SeSAC_2GD  #SeSAC_2GD폴더로 이동

GitHub와 연결이 된다.

 

4. GitHub로 전송

작업공간에서 코드를 수정했으면 저장한 후 Git Bash에

git add .  #staging 영역에 저장 (임시 저장. 취소할 수 있다)
git commit -m "change Readme"  #local repository에 change Readme라는 메모를 쓰고 저장
git push  #remote repository에 저장 (github에 전송)

이렇게 입력하면 GitHub에 전송된다.

 

git status  #작업 상태를 확인
git pull  #github에 저장된 작업물을 가져온다

작업 하기 전 git pull을 꼭 해야한다!