GitHub에서 저장소(repository)를 생성해보자.

 

Organization에서 repository를 생성하는 것과

 

 

개인 계정에서 repository를 생성하는 경우가 있지만,

 

 

repository를 생성하는 것은

 

 

생성되는 위치만 달라지는 것이지 모두 똑같은 repository를 생성하는 것이다.

 

 

하지만, 이렇게 생성되는 repository의 상태는 텅텅비어 있는 경우와 initial commit이 있는 경우로 구분될 수 있다.

 

아래와 같이 README 파일이나 .gitignore 파일을 모두 선택하지 않는 경우에는

 

 

initial commit 조차 없는 텅텅 비어 있는 repository로 만들어진다.

 

 

이후 어떻게 진행하면 된다고 친절하게 가이드 해주고 있다.

그대로 따라해보자.

 

 

브랜치(branch)와 관련된 부분은 가이드의 내용과 다르게 진행했는데,

기본 브랜치로 "main"으로 하라고 환경 설정을 하고 진행하는 방식으로 해봤다.

 

README 파일을 생성하도록 하거나 .gitignore 파일을 포함하도록 하는 경우를 살펴보자.

아래의 예시와 같이 둘 모두를 선택해도 동일하다.

 

 

이렇게 생성하면 README 파일, .gitignore 파일을 등록하는 initial commit이 실행되어

아래와 같이 생성되지 마자 저장소의 내용을 확인할 수 있다.

 

 

저장소 URL을 확인하고

 

 

저 주소로 git clone 받으면 된다.

 

 

정말 간단하지 않은가!? 😅

반응형


옛날 옛날 한 옛날에.... 잠시 궁금했던 git clone 옵션들... [ bare / mirror ]


한 번 테스트 해본다고 마음 먹은지 몇 년만에 갑자기 하고 싶다는 의욕이 불끈! ... 은 거짓말이고

회사 업무 中 [ bare / mirror ]  옵션의 차이에 대한 문의가 있었고

이에 대해서 한 번 살펴보고 싶어졌다!!!


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. 도식화

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




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/*" 이다.



위의 내용에 대해서 잘 생각해보고 용도에 맞춰서 잘 사용하기 바란다~


반응형

+ Recent posts