Accessing files of a repository from the Git server

我的梦境 提交于 2019-12-06 00:03:02

If this is a bare repo, you wouldn't find those file in the repo.git folder.
See "all about "bare" repos": a bare repo has no working tree, and is used for pushing to it (since there is no working tree to keep in sync with an updated branch)

The easiest way to see those file is to clone said bare repo:

git clone /path/to/repo.git /path/to/repo

I know only a hack-ish way to see the list of files in a bare repository without cloning:

GIT_DIR=/path/to/bare.git git log --pretty=format: --name-only --diff-filter=A

You most probably want to sort that output and exclude blank lines:

GIT_DIR=/path/to/bare.git git log --pretty=format: --name-only --diff-filter=A | sort | grep .

Viewing the content of a file is pretty clean though:

GIT_DIR=/path/to/bare.git git show HEAD:path/to/file

If you want to get specific files out of the bare repository but not entire repository, you could redirect the output of git show to a file.

Btw, GIT_DIR=... git cmd is equivalent to git --git-dir=... cmd

Git repositories are often stored on the server as a bare repository. This is effectively the contents of the normal .git directory, and does not include an extracted working copy.

To access files stored in such a repository I recommend cloning the repository. If you want to do this from the server you can do something like git clone file /path/to/bare/repository /path/to/clone.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!