본문 바로가기
제로베이스 데이터 스쿨/일일 스터디 노트

38번째 스터디노트 / 버전관리, Git, Local Repository, Remote Repository

by 김뎀뎀 2023. 2. 24.

※제로베이스 데이터 취업스쿨 11기 수강 중

📗 38번째 공부 내용 요약

 

Git에 대해 배우고, 실습해보았다.

1. 버전 관리와 GIT : 버전관리시스템의 개념과 Git의 용어 학습

2. Local Repository : Local Repository를 생성하고, git innit, add, commit 등 학습

3. Remote Repository : Remote Repository를 생성하고, git push, pull, branch 등 학습

 


📖  38번째 공부 내용 자세히

 

1. 버전관리와 GIT

 

1) 버전관리

  • Source Data + History, 버전관리 시스템은 파일에 대해서 데이터와 이력을 관리해줄 수 있다
  • Local Version Control System → Centrallized Version Control System → Distributed Version Control System
  • 요즘 기업들은 대부분 SVN 혹은 Git을 사용하고 있다

 

2) Git 기본 용어

  • Repository : 소스코드가 저장되어 있는 여러 개의 Branch가 모여 있는 디스그 상의 물리적 공간
  • Checkout : 특정 시점이나 Branch의 소스코드로 이동하는 것
  • Stage : 작업할 내용이 올라가는 임시 저장 영역
  • Commit : 작업할 내용을 Local Repository에 저장하는 과정
  • Tag : 임의의 commit 위치에 쉽게 찾아갈 수 있도록 붙여놓은 이정표
  • Push : Local Repository의 내용 중 Remote Repository에 반영되지 않은 commit을 Remote Repository로 보내는 과정
  • Pull : Remote Repository의 내용 중 Local Repository에 반영되지 않은 내용을 가져와서 Local Repository에 저장하는 과정
  • Branch : 특정 시점(commit 단위)에서 분기하여 새로운 commit을 쌓을 수 있는 가지를 만드는 것
  • Merge : branch의 반대 개념으로 하나의 branch를 다른 branch와 합치는 과정

 

 

2. Local Repository

 

1) Local Repository 구성

  Working Directory : 실제 소스파일, 생성한 파일 들이 존재

  Index(Stage) : git add한 파일들이 존재, 준비영역의 역할 

  HEAD : git commit한 파일들이 존재, 최종 확정본

 

 

2) Local Repository 생성

 

■ Working Directory 생성

mkdir <dirctory_name>

 

■ Git init

디렉토리에서 git을 초기화하는 명령어 git init을 사용하면 해당 디렉토리를 git이 관리하기 시작

git init

 

■ 파일 생성

 

touch 명령어를 통해 빈 파일 생성 가능

touch <file_name>

 

■ Git Status

git 에 존재하는 파일 확인

git status

 

■ Git Add

Working Directory에서 변경된 파일을 index(stage)에 추가

git add <file_name>

 

■ Git Commit

Index(stage)에 추가된 변경사항을 HEAD에 반영(확정)

git commit -m "commit에 대한 설명" <file_name>

 

 

3. Remote Repository

 

1) Github에서 Remote Repository 생성

  • README file : 프로젝트에 대한 설명, 사용방법, 라이센스, 설치방법 등에 대한 내용을 기술하는 파일
  • .gitignore : Git 버전 고나리에서 제외할 파일 목록을 지정하는 파일, 사용자가 원치않은 파일들을 자동으로 commit대상에서 제외시켜 줌

 

2) Remote Repository 등록

 

■ Remote Repository 등록

Local Repository에 연동할 Remote Repository를 등록

git remote add origin https://<username>:<token>@gitub.com/<repository>.git

 

3) Remote Repository에 변경내용 Push하기

 

■ Git Push

Local Repository(Head)에 반영된 변경 내용을 Remote Repository에도 반영하기 위해 Git Push 사용

git push origin <branch_name>

 

■ Git Pull

Remote Repository의 내용에 맞춰 Local Repository를 갱신하기 위해 Git Pull 사용

git pull origin <branch_name>

 

4) Remote Repository 복제

Local Repository를 생성하지 않은 상태에서 Git Clone 명령을 사용하여 Remote Repository를 Local에 복제할 수 있음

 

■ Git Clone

git clone https://<username>:<token>@gitub.com/<repository>.git

 

5) Branch

 

■ Branch 조회

# Local Branch
git branch

# Remote Branch
git branch -r

# Local + Remote Branch
git branch -a

 

■ Branch 생성

# Local Branch
git branch <branch_name>

# Remote Branch - Local에서 생성한 branch를 push
git push origin <branch_name>

 

■ Branch 이동

git checkout <branch_name>

 

■ Branch 생성+이동

git checkout -b <branch_name>

 

■ Branch 삭제

# Local Branch
git branch -d <branch_name>

# Remote branch
git push origin --delete <branch_name>

 


➰ 38번째 후기

알고만 있었던 github가 무엇인지 배우고, 직접 사용도 해봤던 수업!

코드들은 간단했는데, 개념이 익숙치 않아서 이해하는 데 시간이 들었던 것 같다.

강사님께서  여러번 해봐야 익숙해질 것이라 말씀하셨는데 정말 그랬던 것~

차차 적응해나가보자~


※본 내용은 제로베이스 데이터 취업 스쿨에서 제공하는 학습 내용에 기반합니다.