Git
[Git] 버전관리 시스템
qoth_0
2023. 12. 6. 18:15
728x90
반응형
버전관리 시스템

- Working Directory에서 작업 후 새로운 버전이 될 후보군은 Staging Area로 이동
- 파일 생성/ 수정 후
- Staging Area
- git add .
- 이 단계에서는 local repository로 파일을 넣기 위한 대상 목록 관리
- stage, 인덱스는 Staging을 가리키는 용어
- 로컬저장소로 넣으면, 그때부터 이력이 생성
- 로컬 저장소(local repo)
- git commit -m “커밋 메세지”
- staging area에서 commit하고 나면 새로운 버전이 생성
- 이때 staging area는 비워지게 됨
- 원격저장소(remote repo)
- git push origin main을 통해 local repository에서 원격 저장소로 업로드(push)하여 반영
실습

파일 생성, 내용 입력 후
git add를 하면 staging area에 올라감
git commit하면 로컬 레포지토리에 올라감 → 새버전 만들어짐
git push 하면 origin(remote) repository에 올라감 → 만든 버전을 밀어 넣음

test2, test3파일 생성 및 기존 test1파일 수정 후 git status하면

위처럼 파일들의 상태를 볼 수 있다.

git add test2.txt로 test2만 add
→ changes to be committed (staging에 올라간상태)
→ test2만 커밋가능

커밋한 모습

git log로 커밋 이력을 확인할 수 있음
Initial commit은 최초 레포지토리 생성 시 발생하는 것

git push하면

깃허브(RemoteRepository)에도 올라오는 것을 확인할 수 있음
728x90
반응형