Git

[Git] GitHub 이용하기

챌링킴 2021. 5. 29. 17:15
반응형

1) GitHub(깃허브) 란?

- Git으로 버전관리한 코드를 올릴 수 있는 클라우드 서버

- 단순한 저장만 하는 것이 아니라 다른 유저들과 함께 코드를 공유하고 온라인으로 하나의 프로그램을 같이 제작할 수 있게 만듦

 

2) GitHub 가입하기

https://github.com 

 

GitHub - 세계가 소프트웨어를 빌드하는 곳

GitHub is where over 65 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 feat...

github.com

 

3) GitHub 이용하기

 

1. Repository(로컬 저장소) 생성하기

** Repository(로컬 저장소) : 저장소, 파일이나 폴더를 저장해두는 저장소 **

Repository를 저장할 위치의 경로에서 Git Bash을 실행한 후, git init 입력

컨트롤 + L : 화면 클리어
pwd : 현재 디렉토리 경로를 표시
ls : 현재 디렉토리에 디렉토리와 파일을 표시
cd : 다른 디렉토리로 이동
cd ..  : 상위 디렉토리로 이동
cd 디렉토리이름 : 해당 리렉토리로 이동
ls -al : 폴더가 안보일 때

 

2. Repository에 저장할 파일 준비하기

ex) README.md, index.html, style.css, ...

 

3. 버전관리 파일 선택하여 Repository에 임시추가

git add README.md 입력

 

4. 버전관리 파일 커밋(확정)하기

git commit -m "README.md를 추가했어요." 입력

 

💫 에러가 발생하는 경우 💫

더보기

Author identity unknown
*** Please tell me who you are.
Run
  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got 'admin@DESKTOP-R2NKGM0.(none)')

💌 해결방법 
git config --global user.email "깃허브에 사용할 이메일주소"
git config --global user.name "이름"

다시 실행
git commit -m "README.md를 추가했어요."

 

5. 로그 확인하기
git log

 

6. 여러 파일을 선택하기

git add .


7. 여러파일 커밋하기

git commit -m "모든 파일 추가"

 

8. 로그 확인하기

git log

 

9. 로컬 저장소에 github 저장소 주소 설정하기

git remote add origin https://github.com/rinlab/frontend.git

 

10. 만든 커밋을 github에 푸시하기

git push -u origin master

 

💫 브랜치 변경 에러가 발생하는 경우 💫

 

4) 원격 저장소(github)의 자료를 내 컴퓨터에 받아오기

 

1. 디렉토리 이동

cd D:\frontend\Clone

 

2. 원격 저장소에서 자료를 복사해서 가져오기

git clone https://github.com/rinlab/frontend.git (폴더 생성)
git clone https://github.com/rinlab/frontend.git . (파일만 생성)

 

3. 폴더 및 파일을 삭제
rm -rf Clone

4. README.md와 index.html 파일을 수정해보기

5. git add .

6. git commit -m "README.md, index.html 파일 수정"

7. git push -u origin master

 

5) 다른 사람들과 협업하기

 

1. 나의 깃허브 사이트 접속 후 repository 선택

 

2. setting 클릭

 

3. manage access 클릭

 

4. 비밀번호 입력

 

5. invite a collaborators 버튼 클릭

 

6. 상대방 이메일 또는 이름을 등록

 

7. 상대방이 메일 확인

반응형

'Git' 카테고리의 다른 글

[Git] GitHub Pages 만들기  (0) 2021.06.20
[Git] Git 설치하기  (0) 2021.05.29
[Git] Git 버전관리 장점, 특징  (0) 2021.05.29