GitHub Git Cheat Sheet
Git 설치하기 GitHub은 일반적으로 많이 사용되는 저장소 관련 작업을 위한 데스크톱 클라이언트와 함께, 더 복잡한 작업을 위해 자동으로 업데이트되는 Git command line 에디션을 제공합니다. Windows
training.github.com
01. GITHUB란?
- 원격저장소
- 분산 버전 관리 시스템인 깃(Git)을 호스팅하는 웹 호스팅 서비스
- 소스코드를 내컴퓨터에서 인터넷으로 올려주는 공간
02. GITHUB의 쓰임
- 소스코드 저장 & 버전관리 & 소스코드 공유
- 협업공간
03. GITHUB 웹호스팅 하는 법
https://opentutorials.org/course/3084/18891
웹호스팅 github pages - 생활코딩
github pages 로 실습을 하는데 문제가 생겼다면 netlify.com 을 이용하는 아래 수업을 참고해주세요. netlify.com 으로 웹호스팅 하기 바로가기 --- 직접 웹서버를 운영하는 일은 쉽지 않은 일입니다. 우
opentutorials.org
04. GITHUB에서 사용하는 GIT 명령어들
https://training.github.com/downloads/ko/github-git-cheat-sheet/
GitHub Git Cheat Sheet
Git 설치하기 GitHub은 일반적으로 많이 사용되는 저장소 관련 작업을 위한 데스크톱 클라이언트와 함께, 더 복잡한 작업을 위해 자동으로 업데이트되는 Git command line 에디션을 제공합니다. Windows
training.github.com
Git - Reference
Reference
git-scm.com
https://hackmd.io/@oW_dDxdsRoSpl0M64Tfg2g/ByfwpNJ-K
Git 명령어 총정리집 (by 코딩알려주는 누나❤) - HackMD
# Git 명령어 총정리집 (by 코딩알려주는 누나❤)  안녕하세요 여러분 :)
hackmd.io
05. GITHUB에 깃허브repository(저장소) 생성하기
방법1
- ➕ 버튼 클릭
- New repository 클릭 (저장소를 만드는 화면 뜸)
- repository name 작성
- readme 선택 (권장)
- public or private 선택
- create repository
방법2
- New 버튼 클릭 (저장소를 만드는 화면 뜸)
- repository name 작성
- readme 선택 (권장)
- public or private 선택
- create repository
깃허브repository 생성 시 주의사항
- 이미 깃이 관리하고 있는 파일을 업로드할 것이므로 아래의 사항은 미체크하기
06. 로컬 repository에서 GITHUB repository에 업로드하기 (git push, git remote)
1) 로컬 repository 생성
## 내 pc 에서
git init
2) 브랜치명 변경
## 깃허브는 기본 브랜치이름을 main으로 사용하기 때문에 로컬브랜치명도 변경함
git branch -M main
3) 로컬에서 원격저장소에 업로드하기
git push -u <원격저장소주소> <올릴로컬브랜치명>
git push -u https://github.com/jaeheela/github-practice.git main
4) 변수 사용하기 (git remote)
- 주소를 변수에 저장해서 사용 가능
## <변수명>에 <저장소주소> 저장
git remote add 변수명 저장소주소
## origin = https://github.com/jaeheela/github-practice.git
(base) jaeheela@Jaehees-MacBook-Air git-practice % git remote add origin https://github.com/jaeheela/github-practice.git
5) 앞으로 push 시 입력될 명령어 (git push)
git push -u https://github.com/jaeheela/github-practice.git main
## 간단해짐
git push -u origin main
## (참고) 실은 -u는 방금 입력한 주소를 기억하라는 뜻
## -u 붙여서 1번 했었으면 나중엔 git push 까지만 입력해도 알아서 잘됨
## 진짜로 git push만 해보셈
## 더 간단해짐
git push
6) git remote -v
## (참고) 변수목록을 살펴보고 싶으면 git remote -v 입력
(base) jaeheela@Jaehees-MacBook-Air git-practice % git remote -v
origin https://github.com/jaeheela/github-practice.git (fetch)
origin https://github.com/jaeheela/github-practice.git (push)
(base) jaeheela@Jaehees-MacBook-Air git-practice % git remote
origin
06. 원격 저장소 이름 변경하는 법
git remote rename <old_name> <new_name>
07. 원격저장소에 있던거 그대로 내려받기 (git clone)
cd /Users/jaeheela/Desktop/my-practice
git clone https://github.com/jaeheela/github-practice.git
(base) jaeheela@Jaehees-MacBook-Air my-practice % git clone https://github.com/jaeheela/github-practice.git
Cloning into 'github-practice'...
remote: Enumerating objects: 32, done.
remote: Counting objects: 100% (32/32), done.
remote: Compressing objects: 100% (17/17), done.
remote: Total 32 (delta 5), reused 32 (delta 5), pack-reused 0
Receiving objects: 100% (32/32), done.
Resolving deltas: 100% (5/5), done.
## 프로젝트로 들어가 작업 가능
## [git log]를 입력하면 프로젝트 내역들을 그대로 이 컴퓨터에 똑같이 복사된 것을 알 수 있음
(base) jaeheela@Jaehees-MacBook-Air github-practice % git log
commit 4bef427634d02ab811d4304a09ced5cd87e25429 (HEAD -> main, origin/main, origin/HEAD)
Author: jaeheela <jhla456@kakao.com>
Date: Thu Mar 23 10:32:14 2023 +0900
add gitignore
commit 95a494d72308c25f158f7f1b3b2e8ba6cc6b0669
Author: jaeheela <jhla456@kakao.com>
Date: Thu Mar 23 03:31:50 2023 +0900
edit
commit cad7dfde5f48c2c4ce43a6473fdaddb088a041c9
Merge: 0ca018f 02fe28d
Author: jaeheela <jhla456@kakao.com>
Date: Thu Mar 23 02:42:26 2023 +0900
Merge branch 'my-idea'
commit 02fe28dba895f59a539c0ae170e88e3a9f70b655
Author: jaeheela <jhla456@kakao.com>
:
08. .gitignore 파일
- 원격저장소를 효율적으로 쓰고 싶으면 쓸데없는 파일은 commit 해서 올리지 않는게 좋음
- .gitignore 파일을 하나 만들면 저장소에 올리지 않을 파일들을 쉽게 명시가능
- 거기 명시한 파일들은 git add . 해도 스테이징이 되지 않아서 편리
- 프로젝트 폴더 안쪽 최상위 공간에 만들기 - 숨긴파일로 지정됨
ex)
- node_modules 이런 폴더, 개인정보들이 들어있는 .env 파일 (어짜피 package.json 파일만 잘 있으면 터미널에서 npm install 입력하면 자동으로 node_modules 폴더가 생성됨)
- 코드만 있으면 그때그때 실행해서 만들 수 있는 것들
- 코드대로 빌드되어서 자동으로 생성되는 파일들
- 보안적으로 정말 중요한 내용들 : DB 계정에 담긴 파일들, …
참고 링크 들어가서 작성 패턴 확인하기
https://www.atlassian.com/git/tutorials/saving-changes/gitignore
.gitignore file - ignoring files in Git | Atlassian Git Tutorial
Git ignore patterns are used to exclude certain files in your working directory from your Git history. They can be local, global, or shared with your team.
www.atlassian.com
.gitignore 예시
##추가한 파일들이 보이지만..!
base) jaeheela@Jaehees-MacBook-Air git-practice % git status
On branch main
Untracked files:
(use "git add <file>..." to include in what will be committed)
.gitignore
secret-animal
nothing added to commit but untracked files present (use "git add" to track)
##[.gitignore]에 [secret-animal]을 추가하니..! [secret-animal]은 사라짐!!
(base) jaeheela@Jaehees-MacBook-Air git-practice % git status
On branch main
Untracked files:
(use "git add <file>..." to include in what will be committed)
.gitignore
nothing added to commit but untracked files present (use "git add" to track)
'git' 카테고리의 다른 글
[git] 11. 타인과 협업하는 법 (git pull 후 git push, pull request) (0) | 2024.07.07 |
---|---|
[git] 9. GIT 명령어 없이 이클립스(IDE)만 이용해 소스코드를 GITHUB에 업로드하는 법 (0) | 2024.07.07 |
[git] 8. GIT 파일 복구 (git restore, git revert, git reset) (0) | 2024.07.07 |
[git] 7. GIT 브랜치 병합 (git rebase, git merge --squash) (0) | 2024.07.07 |
[git] 6. GIT 브랜치 (git branch, git switch, git log, git merge, git merge -d) (0) | 2024.07.07 |