git의 구조-git 객체(git LT vol.2)
5556 단어 Git
주로 git 초급자를 겨냥한 내용입니다.
슬라이딩 모드로 보시면 좋을 것 같아요.
git 안에 있는 걸 알면 git가 더 즐거워져요!
이번에는git의 사용방법이 아니라 메커니즘입니다.
나는 알면 문제를 처리하기 쉽다고 생각한다!
git 객체
git는 다음과 같은 조합을 통해 창고와 지점 등을 표현한다
.git/object에 저장
git 객체
이런 인상
그럼 당장우리 다 같이git/object 보자!
빈 창고를 만들 때 대상을 만들지 않습니다
$ mkdir explore-dot-git && cd explore-dot-git && git init
$ find .git/objects -type f
$
git add 전에도 아무것도 만들지 않습니다
$ echo "Alchol 9%" > strong.txt
$ find .git/objects -type f
$
git add 이후 생성 대상
$ git add strong.txt
$ find .git/objects -type f
.git/objects/29/032df2fd6343ea93bc2c00cd5e93128ba1997f
blocb 객체
git cat-file을 통해 대상을 찾을 수 있습니다
cat-file-t(유형)
$ git cat-file -t 29032df2fd6343ea93bc2c00cd5e93128ba1997f
blob
cat-file-p(내용)$ git cat-file -p 29032df2fd6343ea93bc2c00cd5e93128ba1997f
Alchol 9%
블로그 대상에 파일 내용을 저장했네요!그러니까blb 대상은 파일 내용인 것 같아요.
git commiit 해볼게요.
$ git commit -m 'add strong.txt'
[master (root-commit) 5fd34a2] add strong.txt
1 file changed, 1 insertion(+)
create mode 100644 strong.txt
개체 2개 추가$ find .git/objects -type f
.git/objects/29/032df2fd6343ea93bc2c00cd5e93128ba1997f
.git/objects/48/b394fb164aeb3b5482f3123721df65e208d309
.git/objects/5f/d34a2411bf91577399fd6b9647e37d59e31fa8
추가된 두 대상을 살펴보자!commiit 대상 (첫 번째 commiit)
cat-file-t(유형)
$ git cat-file -t 5fd34a2411bf91577399fd6b9647e37d59e31fa8
commit
cat-file-p(내용)$ git cat-file -p 5fd34a2411bf91577399fd6b9647e37d59e31fa8
tree 48b394fb164aeb3b5482f3123721df65e208d309
author sunadorinekop <[email protected]> 1543332950 +0900
committer sunadorinekop <[email protected]> 1543332950 +0900
add strong.txt
commiit 대상은 commiit 정보인 것 같아요!tree 객체
cat-file-t(유형)
$ git cat-file -t 48b394fb164aeb3b5482f3123721df65e208d309
tree
cat-file-p(내용)$ git cat-file -p 48b394fb164aeb3b5482f3123721df65e208d309
100644 blob 29032df2fd6343ea93bc2c00cd5e93128ba1997f strong.txt
tree 대상은 디렉터리 구조의 정보인 것 같아요!이 목록은strong입니다.txt가 있습니다. 해시 값은 29032d입니다.그런 거 알아요!
지금까지의 인상.
이런 느낌?
commit > tree > blob
그럼 다시 해볼게요.
게다가
$ echo "Alchol 3%" > horoyoi.txt
$ git add horoyoi.txt
$ git commit -m 'add horoyoi'
Object 추가$ find .git/objects -type f
.git/objects/29/032df2fd6343ea93bc2c00cd5e93128ba1997f
.git/objects/47/50679d8ca0d3379dae8abaed6b6013583de548
.git/objects/48/b394fb164aeb3b5482f3123721df65e208d309
.git/objects/5f/d34a2411bf91577399fd6b9647e37d59e31fa8
.git/objects/8b/9e22d4a872621a5ae50655f4ef45bbc6b3e6fc
.git/objects/a5/91a631eaff52e0f32df02d4ba80bc17dd044a1
추가된 세 대상을 살펴보자!blocb 객체 (2nd commiit)
cat-file-t(유형)
$ git cat-file -t a591a631eaff52e0f32df02d4ba80bc17dd044a1
blob
cat-file-p(내용)$ git cat-file -p a591a631eaff52e0f32df02d4ba80bc17dd044a1
Alchol 3%
이것은 1st commiit의 느낌과 같기 때문에 문제없습니다commiit 객체 (2nd commiit)
cat-file-t(유형)
$ git cat-file -t 8b9e22d4a872621a5ae50655f4ef45bbc6b3e6fc
commit
cat-file-p(내용)$ git cat-file -p 8b9e22d4a872621a5ae50655f4ef45bbc6b3e6fc
tree 4750679d8ca0d3379dae8abaed6b6013583de548
parent 5fd34a2411bf91577399fd6b9647e37d59e31fa8
author sunadorinekop <[email protected]> 1543333980 +0900
committer sunadorinekop <[email protected]> 1543333980 +0900
add horoyoi
1st commiit의 대상과 다른 것은parent 5fd34a ...
그래?
이것은 2nd commiit 대상의parent 5fd34a입니다...네
즉, commiit 대상은 자신보다 한 발 앞선 commiit 대상만 안다
commiit 대상의 점
git
1st commit <- 2nd commit <- 3rd commit ...
그리고git 대상은 자신보다 먼commiit를 가리키며commiit의 역사를 표현한다
이거 고장나면 쓰레기 더미 고장나!!(git push-f 등)
tree 개체(2nd commiit)
cat-file-t(유형)
$ git cat-file -t 4750679d8ca0d3379dae8abaed6b6013583de548
tree
cat-file-p(내용)$ git cat-file -p 4750679d8ca0d3379dae8abaed6b6013583de548
100644 blob a591a631eaff52e0f32df02d4ba80bc17dd044a1 horoyoi.txt
100644 blob 29032df2fd6343ea93bc2c00cd5e93128ba1997f strong.txt
아까 commit에서 만든 horoyoi.txt 추가tree 대상이 이 디렉터리의 파일 등 일람 정보를 볼 수 있습니다
이상
블로그,commiit,tree에 대해 어떤 인상을 가지고 계십니까?
추가 질문
strong.txt에'더블 레몬'을 붙여서 3rd commiit를 쓰면 어떨까요?
현재 strong입니다.txt의 블로그 대상에 "double lemon"추가현재 strong입니다.txt의 blocb 대상과 차이점을 새로운 blocb 대상으로 만들기
추가 질문
strong.txt에'더블 레몬'을 붙여서 3rd commiit를 쓰면 어떨까요?
현재 strong입니다.txt의 블로그 대상에 "double lemon"추가현재 strong입니다.txt의 blocb 대상과 차이점을 새로운 blocb 대상으로 만들기
Reference
이 문제에 관하여(git의 구조-git 객체(git LT vol.2)), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/kumagaias/items/3dba1a9c46ce87b60565텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)