[git] 1. init, add, commit

허성재's avatar
Sep 04, 2024
[git] 1. init, add, commit
설치를 안했다면 설치하고 오자.
초기설정도 하고 오자.
$ git config --global user.name "John Doe" $ git config --global user.email johndoe@example.com
 
폴더를 하나 만들자 나는 ex01로 만들었다.
notion image
여기에 마우스 우클릭을 하면
 
notion image
 
Git Bash를 열수 있다.
notion image
뭔가 있어보인다.
여기에
💡
git init
notion image
을 쳐준다.
 
notion image
인제 이폴더는 git으로 관리할수 있다. 숨김폴더에 .git이라는 폴더도 생긴걸 볼수 있다.
나는 여기에 예쁜사진.txt 파일을 만들어보겠다.
notion image
 
 
💡
git status
git status를 쳐보자
notion image
먼가 빨간게 뜬다. 뭔가 바뀐게 있다는 소리다.
 
💡
git add .
 
git add .을 치고 git status를 치게되면
notion image
빨간 글이 초록글로 바뀌며 stage에 올라간 걸 볼 수 있다. 위에 no commits yet인걸 보니 커밋을 해야한다.
나는
💡
git commit -m”예쁜사진”
으로 예쁜사진이라는 메세지를 넣어 커밋을 하겠다.
 
💡
git log
git log를 쳐보게 되면 커밋이 되어있는걸 볼수있다.
notion image
 
이렇게 하고 git status를 쳐보면
notion image
 
이런 상태를 볼수 있다.
 
똑같이 만들어보자 이번엔 노을사진.txt를 만들겠다
똑같이 git add . 과 git commit을 하고 git log를 찍어보면
notion image
차곡 차곡 쌓이는걸 볼 수 있다.
만약 예쁜사진 안의 글을 수정하면 어떻게될까?
notion image
git status에서 보면 뭐가 또 생겼다.
이친구도 add와 커밋을 해주자.
로그를 찍어보면
notion image
이렇게 된다.
Share article

heo-gom