베어 (Bare) 저장소와 비 -Bare 저장소의 실제 차이점은 무엇입니까?
Git의 베어 및 비 베어 / 기본 리포지토리에 대해 읽었습니다. 나는 그들 사이의 차이점에 대해 (이론적으로) 잘 이해하지 못했고 왜 베어 저장소에 "푸시"해야 하는지를 알 수 없었습니다. 거래는 다음과 같습니다.
현재 3 대의 다른 컴퓨터에서 프로젝트를 수행하는 유일한 사람이지만 나중에 더 많은 사람들이 참여할 것이므로 버전 제어에 Git을 사용하고 있습니다. 모든 컴퓨터에서 Bare Repo를 복제하고 그 중 하나에서 수정을 마치면 Bare Repo로 변경 내용을 커밋하고 푸시합니다. 내가 읽은 내용에서 베어 저장소에는 "작업 트리"가 없으므로 베어 저장소를 복제하면 "작업 트리"가 없습니다.
워킹 트리는 프로젝트의 커밋 정보, 분기 등을 저장한다고 생각합니다. 그것은 맨손 저장소에 나타나지 않을 것입니다. 따라서 작업 트리를 사용하여 저장소에 커밋을 "밀어 넣는"것이 더 나을 것 같습니다.
그렇다면 베어 저장소를 사용해야하는 이유는 무엇입니까? 실질적인 차이점은 무엇입니까? 그것은 더 많은 사람들이 프로젝트를 수행하는 데 도움이되지 않을 것이라고 생각합니다.
이런 종류의 일에 대한 당신의 방법은 무엇입니까? 제안?
Bare 저장소와 Bare가 아닌 저장소의 또 다른 차이점은 Bare 저장소에 기본 원격 오리진 저장소 가 없다는 것 입니다.
~/Projects$ git clone --bare test bare
Initialized empty Git repository in /home/derek/Projects/bare/
~/Projects$ cd bare
~/Projects/bare$ git branch -a
* master
~/Projects/bare$ cd ..
~/Projects$ git clone test non-bare
Initialized empty Git repository in /home/derek/Projects/non-bare/.git/
~/Projects$ cd non-bare
~/Projects/non-bare$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master
매뉴얼 페이지에서 git clone --bare
:
또한 리모콘의 분기 헤드는 해당 로컬 분기 헤드에 refs / remotes / origin /에 매핑되지 않고 직접 복사됩니다. 이 옵션을 사용하면 원격 추적 분기 나 관련 구성 변수가 만들어지지 않습니다.
베어 (Bare) 리포지토리를 생성 할 때 Git은 베어 리포지토리가 여러 원격 사용자의 오리진 리포지토리 역할을한다고 가정하므로 기본 원격 오리진을 생성하지 않습니다. 이것이 의미하는 것은 Git이 작업 공간이 없으면 베어 리포지토리에 대한 변경 사항을 커밋하지 않는다고 가정하기 때문에 기본 git pull
및 git push
작업이 작동하지 않는다는 것입니다.
~/Projects/bare$ git push
fatal: No destination configured to push to.
~/Projects/bare$ git pull
fatal: /usr/lib/git-core/git-pull cannot be used without a working tree.
~/Projects/bare$
작업 공간이 저장소의 일부가 아니고 저장소에 작업 공간이 필요하지 않기 때문에 베어 Git 저장소와 비 베어 Git 저장소의 구별은 인공적이고 오해의 소지가 있습니다. 엄밀히 말해 Git 리포지토리에는 리포지토리의 상태를 설명하는 개체가 포함됩니다. 이러한 오브젝트는 모든 디렉토리에 존재할 수 있지만 일반적으로 .git
작업 공간의 최상위 디렉토리에있는 디렉토리에 존재합니다 . 작업 공간은 저장소의 특정 커밋을 나타내는 디렉토리 트리이지만 디렉토리에 존재하거나 전혀 존재하지 않을 수 있습니다. 환경 변수 $GIT_DIR
는 작업 공간이 시작된 저장소에 작업 공간을 링크합니다.
힘내 명령 git clone
과 git init
둘 다 --bare
초기 작업 공간없이 저장소를 만드는 옵션 이 있습니다. 이 망할 놈의 작업 공간 및 저장소의 두 개의하지만 관련 개념을 conflates하고 혼란 용어가 사용하는 불행한 베어 두 개념을 분리 할 수 있습니다.
베어 리포지토리는 .git 폴더 자체에 지나지 않습니다. 즉 베어 리포지토리의 내용은 로컬 작업 리포지토리 내의 .git 폴더 의 내용과 동일 합니다.
- 원격 서버에서 Bare Repository를 사용하여 여러 기고자가 작업을 진행할 수 있습니다.
- 비 베어-작업 트리가있는 것은 프로젝트의 각 제공자의 로컬 컴퓨터에서 의미가 있습니다.
5 년이 너무 늦었지만, 실제로 아무도 그 질문에 대답하지 않았습니다.
그렇다면 베어 저장소를 사용해야하는 이유는 무엇입니까? 실질적인 차이점은 무엇입니까? 그것은 더 많은 사람들이 프로젝트를 수행하는 데 도움이되지 않을 것이라고 생각합니다.
이런 종류의 일에 대한 당신의 방법은 무엇입니까? 제안?
Loeliger / MCullough 책 (978-1-449-31638-9, p196 / 7)에서 직접 인용하려면 :
베어 리포지토리는 거의 사용되지 않는 것 같지만 그 역할은 매우 중요합니다. 협업 개발의 권위있는 중심 역할을하는 것입니다. 다른 개발자
clone
와fetch
Bare 저장소에서push
업데이트 및 업데이트 ... 개발자가push
변경할 저장소를 설정 한 경우 Bare가 있어야합니다. 실제로 이것은 게시 된 리포지토리가 노출되어야하는보다 일반적인 모범 사례의 특별한 경우입니다.
A non-bare repository simply has a checked-out working tree. The working tree does not store any information about the state of the repository (branches, tags, etc.); rather, the working tree is just a representation of the actual files in the repo, which allows you to work on (edit, etc.) the files.
A bare repository has benefits in
- reduced disk usage
- less problems related to remote push (since no working tree is there to get out of synch or have conflicting changes)
Non bare repository allows you to (into your working tree) capture changes by creating new commits.
Bare repositories are only changed by transporting changes from other repositories.
I'm certainly not a Git "expert". I have used TortoiseGit for a while, and wondered what it was talking about when it asked me if I wanted to make a "bare" repo whenever I created one. I was reading this tutorial: https://www.atlassian.com/git/tutorials/setting-up-a-repository/git-init and it addresses the issue, but I still was not quite understanding the concept. This one helped a lot: http://bitflop.com/tutorials/git-bare-vs-non-bare-repositories.html. Now, the first one makes sense too!
According to these sources, in a nutshell a "bare" repo is used on a server where you want to setup a distribution point. It's not intented for use on your local machine. You generally push commits from your local machine to a bare repo on a remote server, and you and/or others pull from that bare repo to your local machine. So your GitHub, Assembla, etc. remote storage / distribution repo is an example where a "bare" repo is created. You would make one yourself if you were setting up your own analogous "sharing center".
This is not a new answer, but it helped me to understand the different aspects of the answers above (and it is too much for a comment).
Using Git Bash just try:
me@pc MINGW64 /c/Test
$ ls -al
total 16
drwxr-xr-x 1 myid 1049089 0 Apr 1 11:35 ./
drwxr-xr-x 1 myid 1049089 0 Apr 1 11:11 ../
me@pc MINGW64 /c/Test
$ git init
Initialized empty Git repository in C:/Test/.git/
me@pc MINGW64 /c/Test (master)
$ ls -al
total 20
drwxr-xr-x 1 myid 1049089 0 Apr 1 11:35 ./
drwxr-xr-x 1 myid 1049089 0 Apr 1 11:11 ../
drwxr-xr-x 1 myid 1049089 0 Apr 1 11:35 .git/
me@pc MINGW64 /c/Test (master)
$ cd .git
me@pc MINGW64 /c/Test/.git (GIT_DIR!)
$ ls -al
total 15
drwxr-xr-x 1 myid 1049089 0 Apr 1 11:35 ./
drwxr-xr-x 1 myid 1049089 0 Apr 1 11:35 ../
-rw-r--r-- 1 myid 1049089 130 Apr 1 11:35 config
-rw-r--r-- 1 myid 1049089 73 Apr 1 11:35 description
-rw-r--r-- 1 myid 1049089 23 Apr 1 11:35 HEAD
drwxr-xr-x 1 myid 1049089 0 Apr 1 11:35 hooks/
drwxr-xr-x 1 myid 1049089 0 Apr 1 11:35 info/
drwxr-xr-x 1 myid 1049089 0 Apr 1 11:35 objects/
drwxr-xr-x 1 myid 1049089 0 Apr 1 11:35 refs/
Same with git --bare
:
me@pc MINGW64 /c/Test
$ ls -al
total 16
drwxr-xr-x 1 myid 1049089 0 Apr 1 11:36 ./
drwxr-xr-x 1 myid 1049089 0 Apr 1 11:11 ../
me@pc MINGW64 /c/Test
$ git init --bare
Initialized empty Git repository in C:/Test/
me@pc MINGW64 /c/Test (BARE:master)
$ ls -al
total 23
drwxr-xr-x 1 myid 1049089 0 Apr 1 11:36 ./
drwxr-xr-x 1 myid 1049089 0 Apr 1 11:11 ../
-rw-r--r-- 1 myid 1049089 104 Apr 1 11:36 config
-rw-r--r-- 1 myid 1049089 73 Apr 1 11:36 description
-rw-r--r-- 1 myid 1049089 23 Apr 1 11:36 HEAD
drwxr-xr-x 1 myid 1049089 0 Apr 1 11:36 hooks/
drwxr-xr-x 1 myid 1049089 0 Apr 1 11:36 info/
drwxr-xr-x 1 myid 1049089 0 Apr 1 11:36 objects/
$ git help repository-layout
A Git repository comes in two different flavours:
- a .git directory at the root of the working tree;
- a .git directory that is a bare repository (i.e. without its own working tree), that is typically used for exchanging histories with others by pushing into it and fetching from it.
'Programming' 카테고리의 다른 글
Keras 입력 설명 : input_shape, units, batch_size, dim 등 (0) | 2020.05.19 |
---|---|
모든 웹 요청이 브라우저 쿠키를 보내나요? (0) | 2020.05.19 |
Visual Studio C # 문 축소 (0) | 2020.05.19 |
페이지에서 브라우저 인쇄 옵션 (헤더, 바닥 글, 여백)을 비활성화 하시겠습니까? (0) | 2020.05.19 |
Bash에서 디렉토리의 부모 얻기 (0) | 2020.05.19 |