728x90
git add
git을 사용하는 이유: git의 commit 기능을 통해 파일의 상태를 기록할 수 있음. 파일을 수정하다가 특정 시점으로 돌아갈 수 있음.
현재 폴더(디렉토리)에서 git을 사용하려면
해당 디렉토리 위치에서 터미널을 열고 git init을 입력하면 됨. (아래 사진은 vscode 터미널)
git init
git init을 완료하면 이제 디렉토리 내에서 코드를 수정하거나, 새로운 파일을 만드는 등 모든 작업이 기록됨.
이제 디렉토리 내 수정한 내용을 기록하자
git add 해당파일명 → git commit -m "기록메세지" 를 차례로 입력하면 이제 수정한 내용을 기록하게됨.
git add 파일명
git commit -m "기록할 메세지"
수정한 모든 내용을 commit하려면 git add . 를 입력하면 됨.
Staging area & repository
- staging area: commit을 하기 전 수정 내용이 대기하는 곳
- staging area에 파일을 넣는 것 = staging
- git add 를 통해 staging
- repository는 commit된 파일을 모아두는 곳
- repository 내용을 보려면 작업폴더 안에 .git 폴더를 열어보면 됨. (mac: command + shfit + . 키를 누르면 확인 가능)
git status
- 지금 변경된 파일, 스테이징된 파일을 쭉 알려줌.
git restore --staged 파일명
- 스테이징된 파일을 취소할 때 입력
git log --all --oneline
git log --all --oneline --graph
- commit 기록을 한 눈에 보기
- --graph 옵션을 넣으면 그래프를 보여주는데 vim으로 보여줘서 별로. vscode를 사용할 경우, 확장에서 'Git Graph'를 설치하면 예쁜 그림을 볼 수 있음.
Reference
https://codingapple.com/course-status/
↑ 정말 잘 가르쳐주심. 설명이 귀에 꽂힘.
728x90
반응형
'Study > Git' 카테고리의 다른 글
[Git] git 사용법 - git clone, pull (0) | 2024.03.22 |
---|---|
[Git] Github 사용법 - git push (0) | 2024.03.22 |
[Git] git branch 만들기 (0) | 2024.03.22 |