Git git clone [bare/mirror] 정리

황제낙엽 2021.09.03 10:30 조회 수 : 889

0. clone

    - 일단 무조건 clone 해봤다.
 

$ git clone git@github.com:tensorflow/tensorflow.git ./tensorflow-normal

Cloning into './tensorflow-normal'...

remote: Enumerating objects: 3, done.

remote: Counting objects: 100% (3/3), done.

remote: Compressing objects: 100% (3/3), done.

remote: Total 796000 (delta 0), reused 3 (delta 0), pack-reused 795997

Receiving objects: 100% (796000/796000), 453.08 MiB | 8.29 MiB/s, done.

Resolving deltas: 100% (643770/643770), done.

Checking out files: 100% (19052/19052), done.

 

$ du -hs ./tensorflow-normal
690M    ./tensorflow-normal

 

$ git clone --no-checkout git@github.com:tensorflow/tensorflow.git ./tensorflow-no

Cloning into './tensorflow-no'...

remote: Enumerating objects: 3, done.

remote: Counting objects: 100% (3/3), done.

remote: Compressing objects: 100% (3/3), done.

remote: Total 796000 (delta 0), reused 3 (delta 0), pack-reused 795997

Receiving objects: 100% (796000/796000), 453.51 MiB | 8.85 MiB/s, done.

Resolving deltas: 100% (643732/643732), done.

 

$ du -hs ./tensorflow-no
475M    ./tensorflow-no

 

$ git clone --bare git@github.com:tensorflow/tensorflow.git ./tensorflow-bare

Cloning into bare repository './tensorflow-bare'...

remote: Enumerating objects: 3, done.

remote: Counting objects: 100% (3/3), done.

remote: Compressing objects: 100% (3/3), done.

remote: Total 796000 (delta 0), reused 3 (delta 0), pack-reused 795997

Receiving objects: 100% (796000/796000), 455.34 MiB | 8.28 MiB/s, done.

Resolving deltas: 100% (643815/643815), done.

 

$ du -hs ./tensorflow-bare
477M    ./tensorflow-bare

 

$ git clone --mirror git@github.com:tensorflow/tensorflow.git ./tensorflow-mirror

Cloning into bare repository './tensorflow-mirror'...

remote: Enumerating objects: 1124, done.

remote: Counting objects: 100% (1124/1124), done.

remote: Compressing objects: 100% (1116/1116), done.

remote: Total 1055983 (delta 805), reused 21 (delta 8), pack-reused 1054859

Receiving objects: 100% (1055983/1055983), 1.09 GiB | 8.69 MiB/s, done.

Resolving deltas: 100% (783532/783532), done.

 

$ du -hs ./tensorflow-mirror
1.2G    ./tensorflow-mirror

 

 

1. 정리

    - 위 내용을 표로 정리하면 아래와 같다.

 

구분 

 normal

 --no-checkout

--bare 

--mirror 

objects 

796,000 

796,000 

796,000 

1,055,983 

Receiving Size 

453.08 MiB 

453.51 MiB 

455.34 MiB 

1.09 GiB 

du Size 

690 M 

475 M 

477 M 

1.2 G 

 

 

2. 도식화

    - 위의 상황을 그림으로 설명해보면 아래와 같다.

 

99BA823B5E0C37B425.jpg

3. 설명

    - normal

        . 당연히 commit 이력을 모두 담고 있고, 거기에다가 기본 branch로 설정된 소스코드가 working tree에 존재하게 된다.

    - no-checkout

        . commit 이력을 모두 담고 있고, 아직은 working tree에 소스코드를 넣어놓지는 않은 상태다.

    - bare

        . commit 이력만 담고 있다

    - mirror

        . 일반적인 commit 이력뿐만 아니라, 숨어있는(?) 모든 이력들을 담고 있다.

 

    # 적고나니 이게 뭔 설명인가 싶네.... ^^

 

 

4. 차이점 살펴보기

    - normal vs no-checkout

        . HEAD가 가리키는 기본 branch의 latest commit으로 checkout 했냐/안했냐의 차이만 있다.

        . no-checkout으로 clone 한 뒤에 "git checkout -b master"를 하면 결국 똑같다.

 

    - normal vs bare

        . bare 옵션으로 clone을 하는 것은 개발을 하고자 하는 용도가 아니다. 그러므로 working tree는 없다.

        . normal clone을 했을 때 ".git" 디렉토리 부분만 있는 것이 bare 옵션이기 때문이다.

$ diff ./tensorflow-bare/config ./tensorflow-normal/.git/config

4c4,5

<       bare = true

---

>       bare = false

>       logallrefupdates = true

6a8,11

>       fetch = +refs/heads/*:refs/remotes/origin/*

> [branch "master"]

>       remote = origin

>       merge = refs/heads/master

        . 위의 차이를 보면 알겠지만, bare 옵션으로 clone을 하게 되면 remote를 바라보지 않는다

 

    - bare vs mirror

        . mirror 옵션은 현재 서버에 기록된(?) 모든 사항을 전부 가져오게 된다.

$ nano ./tensorflow-mirror/packed-refs

# pack-refs with: peeled fully-peeled sorted

4be56f381cd000e91f79209aaf150636db6fb840 refs/heads/0.6.0

...

45e1e4598d3ebab316bf87df9160656f524af36c refs/heads/master

e1c85596366f3133c797f153dac34e01589a231f refs/pull/10000/head

c2d4f5e964503d17107123e51139aa8bbf27c57c refs/pull/10007/head

29d57e0360306de6bc9021eec4b633e96f3549f5 refs/pull/10008/head

ad9e6a95e53a4407db44e0436fc5318522e832cf refs/pull/10011/head

...

        . bare 옵션의 경우에는 "refs/heads/*" 항목만 보이지만,

        . mirror 옵션의 경우에는 "refs/pull/*" 항목도 보인다.

        . GitHub에서 Pull-Request를 할 때 사용되는 commit들이 기록되는 위치가 바로 "refs/pull/*" 이다.



출처: https://www.whatwant.com/entry/bare-와-mirror의-차이 [머가필요해]

번호 제목 글쓴이 날짜 조회 수
39 sourcetree - 특정 커밋으로 프로젝트 변경 황제낙엽 2025.08.26 0
38 git clone시 보안에 취약하지만 사용자 아이디와 비번 저장해놓고 사용하기 황제낙엽 2025.08.05 0
37 cherry pick 내가 원하는 커밋만 가져오기 file 황제낙엽 2022.02.17 371
36 Git Extensions Online Manual 황제낙엽 2022.02.17 4441
35 심플한 커밋 이력 조회 (git log --pretty=format) [2] 황제낙엽 2022.01.12 342
34 Git 특정 폴더 및 파일만 clone 하기 (작성중) 황제낙엽 2021.10.08 347
33 git remote set-url file 황제낙엽 2021.09.03 300
» git clone [bare/mirror] 정리 file 황제낙엽 2021.09.03 889
31 Git Repository 이동하기 황제낙엽 2021.09.02 305
30 유용한 Git 명령어 몇가지 황제낙엽 2021.09.02 324
29 Git의 4가지 영역 황제낙엽 2021.09.02 346
28 Git bare repository 황제낙엽 2021.09.02 296
27 git reset의 3가지 옵션 제대로 이해하기 file 황제낙엽 2021.07.31 328
26 이전 커밋으로 되돌리기 (revert, reset) file 황제낙엽 2021.07.31 431
25 Ubuntu 에 Git 설치 황제낙엽 2020.09.13 365
24 Git commit 이력(Merge pull request #00 from repo/branch) 깔끔하게 관리하기 file 황제낙엽 2016.10.04 381
23 10분만에 파악해보는 What is GitHub (Hello World) file 황제낙엽 2016.10.04 554
22 태그(Tag) 생성 file 황제낙엽 2016.09.29 687
21 git 에서 CRLF 개행 문자 차이로 인한 문제 해결하기 file 황제낙엽 2016.09.29 939
20 [Git] SourceTree 에서 Global 변수 세팅 file 황제낙엽 2016.09.27 381