👉 Each time you change your code or etc, git allows you to track version of a project automatically.
So we need a tool (git) to ...
git init
From now on, each time you change something in a file anywhere in this folder, git will track these changes
Do not run in your home folder
Inform and declare "git init" to the file/ directory you will track.
git staus
지금 니 상태가 어때? 라고 물어보는 것...file이 tracking되고 있는지 없는지 알 수 있음. 워킹트리 확인.
git add logo.png index.html style.css
git add {directory name, file name, .(all the file below this directory)}
명시적으로 깃을 track하라고 말해주는 것. staging area에 올림.
git commit --message "added logo in homepage and set width"
git commit -am "content"
add + commit at once ! but the file already should have been tracking.
git commit
can make multiple line of commit message
👉 It has to be specific for workflow & collaboration
git diff
👉 see through what has changed, green part will show you the inserted code since last commit.
git log
👉 It shows the history of what you did.
git log -p
👉 It shows specific history.
git checkout gitidnumber
👉 Go back to the certain point to where the gitidnumber indicates.( You can find the idnumber to git log)
👉 2 steps process
1. Select the file to add to the commit
$git add <file _1_has_modified>
$git commit --message "A meaningful message about this change"
.
.
.
git status
git add
git commit
git reset --hard gitidnumber git reset --soft gitidnumber
👉 Reset to (go back to) the "gitidnumber" version. It does not mean you are going to delete "gitidnumber"
when you want to go back to previous version from current version, you need to revert "current version"
👉 ex ) 1,2,3,4 버전이 있는데....
👉 제일 최근 버전(4)을 리버트하면 기존 커밋은 내버려두고, 그 커밋은 살아있다(그 커밋에서의 변화를 취소한 것이기 때문에...) 제일 최근 이전의 버전(3)이 된다.
👉 그럼 2를 리버트하면 1이 될까? - NO => 충돌 발생
👉 revert 4 > revert 3 > revert2 하면 1이 된다...
👉 반드시 역순으로 하나씩 리버트한다.
👉 나혼자보기위한 파일, 자동으로 생기는 파일 버전관리 안하고 싶은 파일은 .gitignore파일 안에 원하는 파일명 적어서 깃 트랙 안되게 관리 가능
sources
https://backlog.com/git-tutorial/kr/stepup/stepup1_1.html
https://opentutorials.org/course/3839