Git
버전관리 시스템의 종류
✓ 버전관리
여러 파일을 하나의 버전으로 묶어 관리하는 것
버전관리 시스템의 종류
1. 클라이언트 - 서버
- 클라이언트들이 하나의 중앙 서버로부터 각자 필요한 것만 가져와서 작업을 하고 다시 중앙 서버로 보내 통합하는 방식
- SVN, CVS
2. 분산 모델
- 하나의 중앙 서버가 존재하지만, 클라이언트들은 각자의 컴퓨터 저장소에 전체 사본을 가지고 작업하는 방식
- Git
Git의 장점
1. 동시에 작업하는 사람들과 소스코드를 주고받을 필요가 없음
2. 같은 파일을 여러명이 동시에 병렬 개발이 가능
3. 변동 과정을 체계적으로 관리할 수 있고, 언제든지 지난 시점의 버전으로 되돌릴 수 있음
4. 인터넷이 연결되지 않은 곳에서도 개발을 진행할 수 있고, 중앙 서버의 데이터가 유실되어도 다시 복구할 수 있음
Git 설치
Git - Downloads
Downloads macOS Windows Linux/Unix Older releases are available and the Git source repository is on GitHub. GUI Clients Git comes with built-in GUI tools (git-gui, gitk), but there are several third-party tools for users looking for a platform-specific exp
git-scm.com
OS에 맞게 다운로드
Mac의 경우
homebrew로 설치(터미널)
$ brew install git
homebrew가 없다면 homebrew 설치 후 명령어 실행
Git 명령어
프로젝트 디렉토리 내에 로컬 저장소를 생성(init)
(숨겨진 폴더) local repository
- 원하는 프로젝트 디렉토리로 이동 후
$ git init
힌트: Using 'master' as the name for the initial branch. This default branch name
힌트: is subject to change. To configure the initial branch name to use in all
힌트: of your new repositories, which will suppress this warning, call:
힌트:
힌트: git config --global init.defaultBranch <name>
힌트:
힌트: Names commonly chosen instead of 'master' are 'main', 'trunk' and
힌트: 'development'. The just-created branch can be renamed via this command:
힌트:
힌트: git branch -m <name>
/Users/MK/KDT/Git/Day1/.git/ 안의 빈 깃 저장소를 다시 초기화했습니다
git 버전 관리할 파일을 선택(add)
$ git add index.html
커밋(commit)
$ git commit -m 'index.html의 첫 커밋'
[master (최상위-커밋) 52c97e9] index.html의 첫 커밋
1 file changed, 13 insertions(+)
create mode 100644 index.html
✓ 만약 아래와 같이 에러가 발생하는 경우
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.
$ git config --global user.email "you@example.com"
$ git config --global user.name "Your Name"
"you@example.com" 에 자신의 이메일 주소 입력
"Your Name"에 자신의 이름 입력
✓ 입력 확인
$ git config user.email
didansrl123@naver.com
$ git config user.name
moon-123
✓ 입력을 수정하려면 한번 더 입력해서 덮어쓰기
$ git config --global user.email "you@example.com"
$ git config --global user.name "Your Name"
입력 후 다시 커밋 명령어 실행
기록 확인(log)
$ git log
commit 52c97e9bdd397759d3cb878c3d45a3db62cb6f8d (HEAD -> master)
Author: moon-123 <didansrl123@naver.com>
Date: Wed Nov 1 09:55:53 2023 +0900
index.html의 첫 커밋
여러 파일 선택(add .)
이미 커밋한 index.html을 제외하고 README.md, style.css 파일을 생성하였다.
$ git add .
선택된 파일 확인(status)
$ git status
현재 브랜치 master
커밋할 변경 사항:
(use "git restore --staged <file>..." to unstage)
새 파일: README.md
새 파일: style.css
이대로 커밋을 하면 선택된 파일들이 모두 커밋된다.
댓글