AI딥러닝/Git

개발자 필수 코스! Git 설치 및 로컬 저장소 관리 프로세스 정리

Ystory96 2026. 1. 6. 20:27

1. CMD vs GIT 명령어 (with bash)

📁 CMD 명령어 (Windows)

mkdir 폴더명          # 폴더 생성
cd 폴더명            # 폴더 이동
cd ..               # 상위 폴더
dir                 # 목록 보기
cls                 # 화면 지우기
del 파일명           # 파일 삭제
rmdir 폴더명         # 폴더 삭제

cmd명령어와 git명령어를 구분해서 외워두자.

🔧 Git 명령어

기본작업

git init                    # 저장소 초기화
git status                  # 상태 확인
git add .                   # 전체 추가
git add 파일명               # 파일 추가
git commit -m "메시지"       # 저장
git log                     # 히스토리 확인
git log --oneline           # 간단히 보기

되돌리기

git reset HEAD 파일명        # staging 취소
git reset --soft HEAD~1     # commit 취소 (파일 유지)
git reset --hard HEAD~1     # commit 취소 (파일 삭제)
git checkout -- 파일명       # 파일 변경 취소

브랜치

git branch                  # 목록 보기
git branch 이름             # 생성
git checkout 이름           # 전환
git checkout -b 이름        # 생성+전환
git branch -d 이름          # 삭제
git merge 이름              # 병합

원격 작업

git clone URL               # 복제
git remote -v               # 원격 저장소 확인
git push origin 브랜치       # 업로드
git pull origin 브랜치       # 다운로드
git fetch                   # 변경사항만 가져오기

 

 

2. GIT 설치하기

Git download

https://git-scm.com/install/windows

 

Git - Install for Windows

Click here to download the latest (2.52.0) x64 version of Git for Windows. This is the most recent maintained build. It was released on 2025-11-17. Other Git for Windows downloads Standalone Installer Git for Windows/x64 Setup. Git for Windows/ARM64 Setup.

git-scm.com

git install
Git Bash click
open cmd

3. 실행

C:\Users\ez>cd\
C:\>mkdir gittest

C:\>cd gittest

C:\gittest>notepad sam.txt
fatal: detected dubious ownership in repository at 'C:/'
'C:/' is owned by:
        NT SERVICE/TrustedInstaller (S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464)
but the current user is:
        WIN-0U7CDAH78DQ/ez (S-1-5-21-2045449887-3023784119-3244951880-1002)
To add an exception for this directory, call:
        git config --global --add safe.directory C:/

 

C:\gittest>git init
Initialized empty Git repository in C:/gittest/.git/


C:\gittest>git status sam.txt
On branch master
No commits yet
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        sam.txt
nothing added to commit but untracked files present (use "git add" to track)

nothing added to commit but untracked files present (use "git add" to track)


C:\gittest>git add sam.txt
C:\gittest>git status sam.txt
On branch master
No commits yet
Changes to be committed:
  (use "git rm --cached <file>..." to unstage)
        new file:   sam.txt

 

C:\gittest>git commit -m "ver1.0"
[master (root-commit) 9000063] ver1.0
 1 file changed, 1 insertion(+)
 create mode 100644 sam.txt

C:\gittest>git log
commit 900006398bd9cdb459725ad4e2e1418551de3e87 (HEAD -> master)
Author: YeonJuKim <yeonply@naver.com>
Date:   Tue Jan 6 19:40:31 2026 +0900
    ver1.0

 

파일 지우기


C:\gittest>git reset "900006398bd9cdb45972" --hard
HEAD is now at 9000063 ver1.0


다시생성

 

 

4. 반복 (ver. 다양하게 저장할 수 있음)

버전별로 저장하는 방법 실습하기

동영상 서비스가 종료되어 해당 콘텐츠를 재생할 수 없습니다.

 

 

5. 추가내용

(1) 가지뻗기 master에서 kim으로 관리자 변경

C:\git>git branch
* master

C:\git>git branch kim

C:\git>git branch
  kim
* master

C:\git>git checkout kim
Switched to branch 'kim'      (master->kim으로 변경)

C:\git>git branch
* kim

 

(2) kim에게 new 세계의 정보를 가져오도록 merge

DOS
 
C:\git> git merge new

설명: 화면에 Updating... Fast-forward라는 글자가 나오면 성공!

 

(3) log로 합쳐졌는지 확인

DOS
 
C:\git> git log --oneline

설명: 목록 제일 위에 new가 업로드합니다라는 글자가 보인다면 합치기 성공!

 

 

끝.