git checkout <commit_id>
특정시점으로 이동하기 위한 명령어
Commit ID (HashCODE) 는 log를 통해 확인 가능
Commit ID의 앞 일곱자리만 가져와도 버전이동이 가능
checkout을 하면 그버전의 상태로 Working directory 가 변경
Head가 checkout한 버전을 가르킴
참고. Remote + Local Branch 예시
![]()
git branchgit branch -rgit branch -a git branch <branch_name>git push origin <branch_name>git branch --delete <branch_name>git push origin --delete <branch_name>git checkout <branch_name>
- checkout_project 생성
mkdir checkout_project cd checkout_project git init
- file1 생성
touch file1.py git add file1.py git commit -m "add file1"위의 방식으로 file3까지 만들어준 후 실습
git checkout 768e07e
git checkout main
- Remote Repository 생성
⠀-> branch_project라는 이름으로 생성, README.md file 생성- 주소 + Token 복사
- Local Repository로 Clone
touch file1.py
git add file1.py
git commit -m "add file1"
ls
touch file2.py
git add file2.py
git commit -m "add file2"
ls
⠀-> GitHub를 확인하면 Branch 가 생성된 걸 확인 할 수 있음
git branch --delete를 사용하여 지움
🚨 BUT 아직 merge가 안되어 있으면 --delete로 지울 수 없음
⠀⠀그럴 경우는, git branch -D 를 사용해 지우기
(참고)
local에서 지워진 branch가 remote에 남아있을 경우 ,
git pull origin <branch_name>하면 다시 끌어올 수 있음
실제 현업할 때는 remote에 있는 branch는 함부로 삭제하지 않는 것이 좋음!!