Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to view files in bare repositories?

I have a bare repository in my remote. I want to look at files, that is open in an editor and view the code. For listing files, git ls-files master or git ls-tree master. and for viewing single file, I could do git show 100644 But how do I view files in directories. Here is an example:

100644 blob 03ec70a7ab513de8d568450dd8fca93987a22da0    .gitignore
100644 blob 75a85b0137fe1ee0c60bda6dcfac78d2d59a1759    README.md
040000 tree 53a58d85bc833575fdfee86058d88a4928c6fe76    templates

If I do git show 03ec70, it shows the content of .gitignore file

If I do git show 53a58d, it lists the contents of template folder

403.html
404.html
500.html
base.html

But How can I open the individual files to see them. Example: base.html in the above case

like image 442
brain storm Avatar asked May 08 '14 19:05

brain storm


People also ask

Where are files in bare repository?

They are stored as "blobs" in the . git/ directory and they are totally unreachable as "files". To get a visible version of your project, you should clone it and extract it from the bare repository.

How do I see files in a git repository?

The Git Show command allows us to view files as they existed in a previous state. The version can be a commit ID, tag, or even a branch name. The file must be the path to a file. For example, the following would output a contents of a file named internal/example/module.go file from a tagged commit called “release-23”.

Can you pull from a bare repository?

A bare repo is characterized by not having a working copy in the file system. Therefore no file on the disk of a bare repo can be part of the repo, and you can't pull it as a result.

How do you use bare repository?

Using a Bare Repository A bare repository is linked with a local repository, hence the files in . git of local repo should match with the files in the bare repo. First, create a bare repository (See section for the code snippet).


Video Answer


2 Answers

git show ${branch}:templates/base.html
like image 77
William Pursell Avatar answered Oct 22 '22 23:10

William Pursell


If you want more detailed contents of the templates folder, you can use ls-tree with the tree's ID. For example:

git ls-tree 53a58d

Which will show you the full tree entries. From there, you can git cat-file blob or git show them.

For example:

% git ls-tree HEAD
040000 tree 62711729ee3bd52fd75fa4fdd0944c9890f6a249    .nuget
100644 blob b457310ab0fbab34746e9ded04b378241f9b9fe3    GitClient.sln
040000 tree 197b7190b843ef07e78e6589c6edd84bdcdd4082    packages

If I want to look at the subtree packages:

% git ls-tree 197b719
100644 blob df885643f0a23e0307df2c704f1e21b500185344    repositories.config

And if I want to look at the contents of packages/repositories.config at HEAD:

% git cat-file blob df88564
<?xml version="1.0" encoding="utf-8"?>
...etc...
like image 41
Edward Thomson Avatar answered Oct 23 '22 01:10

Edward Thomson