Thomas Koch
Thomas Koch

Reputation: 2931

browse sparse git checkout

In a sparse git checkout, one does not see the folders (directories/trees) that haven't been added via git sparse-checkout add.

I can still "browse" these folders with git cat-file -p HEAD and following the tree hashes.

Is there any tool or trick to make this more comfortable?

Upvotes: 0

Views: 30

Answers (2)

grawity_u1686
grawity_u1686

Reputation: 16122

git show can also show other objects, not only commits, using <commit>:<path> as the specification.

For example, git show @: will list the root tree contents of the HEAD commit, 1 line per file, while git show @:README.txt will show the contents of the specified file.

To browse the tree interactively, use tig and press t to open its 'tree' view.

Upvotes: 0

Thomas Koch
Thomas Koch

Reputation: 2931

I've created this alias in my git config which is already a good enough solution for me:

[alias]
    ls = ls-tree --format='%(objecttype) %(path)' HEAD

It's not nice that:

  • I need to put a slash at the end of a folder to see its content.
  • The output is not as compact as the output of ls.

Upvotes: 0

Related Questions