Skip to main content
Formatting.
Source Link

Another way is possible if you're using tree 1.8.0 sincetree 1.8.0 since it supports supports the --fromfile flag:

   --fromfile  Reads a directory listing from a file rather than the file-system.  Paths provided on the command
   line are files to read from rather than directories to search.  The dot (.)  directory  indicates  that  tree
   should read paths from standard input.

--fromfile

    Reads a directory listing from a file rather than the file-system.  Paths provided on the command line are files to read from rather than directories to search.  The dot (.) directory indicates that tree should read paths from standard input.

We could use git ls-tree to get all non-git-ignored files in a project, and pipe the output to tree.

Assuming we have a git repository, where ignored files are ignored in .gitignore:

git_repo
├── .gitignore
├── bar
│   ├── b.txt
│   └── ignored
├── foo
│   ├── a.txt
│   └── ignored
└── ignored

The following command:

git ls-tree -r --name-only HEAD | tree --fromfile

Gives:

.
├── .gitignore
├── bar
│   └── b.txt
└── foo
    └── a.txt

2 directories, 3 files

Or if you need a specific path:

git ls-tree -r --name-only HEAD foo | tree --fromfile

Gives:

.
└── a.txt

0 directories, 1 file

Caveats

  • Beware that changes such as deleted or renamed files that haven't already been committed can cause git ls-tree to appear out of sync.

Another way is possible if you're using tree 1.8.0 since it supports the --fromfile flag:

   --fromfile  Reads a directory listing from a file rather than the file-system.  Paths provided on the command
   line are files to read from rather than directories to search.  The dot (.)  directory  indicates  that  tree
   should read paths from standard input.

We could use git ls-tree to get all non-git-ignored files in a project, and pipe the output to tree.

Assuming we have a git repository, where ignored files are ignored in .gitignore:

git_repo
├── .gitignore
├── bar
│   ├── b.txt
│   └── ignored
├── foo
│   ├── a.txt
│   └── ignored
└── ignored

The following command:

git ls-tree -r --name-only HEAD | tree --fromfile

Gives:

.
├── .gitignore
├── bar
│   └── b.txt
└── foo
    └── a.txt

2 directories, 3 files

Or if you need a specific path:

git ls-tree -r --name-only HEAD foo | tree --fromfile

Gives:

.
└── a.txt

0 directories, 1 file

Caveats

  • Beware that changes such as deleted or renamed files that haven't already been committed can cause git ls-tree to appear out of sync.

Another way is possible if you're using tree 1.8.0 since it supports the --fromfile flag:

--fromfile

    Reads a directory listing from a file rather than the file-system.  Paths provided on the command line are files to read from rather than directories to search.  The dot (.) directory indicates that tree should read paths from standard input.

We could use git ls-tree to get all non-git-ignored files in a project, and pipe the output to tree.

Assuming we have a git repository, where ignored files are ignored in .gitignore:

git_repo
├── .gitignore
├── bar
│   ├── b.txt
│   └── ignored
├── foo
│   ├── a.txt
│   └── ignored
└── ignored

The following command:

git ls-tree -r --name-only HEAD | tree --fromfile

Gives:

.
├── .gitignore
├── bar
│   └── b.txt
└── foo
    └── a.txt

2 directories, 3 files

Or if you need a specific path:

git ls-tree -r --name-only HEAD foo | tree --fromfile

Gives:

.
└── a.txt

0 directories, 1 file

Caveats

  • Beware that changes such as deleted or renamed files that haven't already been committed can cause git ls-tree to appear out of sync.
Used a more sensible formatting for relative link
Source Link
Zephyro
  • 371
  • 3
  • 4

Another way is possible if you're using tree 1.8.0 since it supports the --fromfile flag:

   --fromfile  Reads a directory listing from a file rather than the file-system.  Paths provided on the command
   line are files to read from rather than directories to search.  The dot (.)  directory  indicates  that  tree
   should read paths from standard input.

We could use git ls-tree to get all non-git-ignored files in a project, and pipe the output to tree.

Assuming we have a git repository, where ignored files are ignored in .gitignore:

git_repo
├── .gitignore
├── bar
│   ├── b.txt
│   └── ignored
├── foo
│   ├── a.txt
│   └── ignored
└── ignored

The following command:

git ls-tree -r --name-only HEAD | tree --fromfile

Gives:

.
├── .gitignore
├── bar
│   └── b.txt
└── foo
    └── a.txt

2 directories, 3 files

Or if you need a specific path:

git ls-tree -r --name-only HEAD: foo | tree --fromfile

Gives:

.
└── a.txt

0 directories, 1 file

Caveats

  • Beware that changes such as deleted or renamed files that haven't already been committed can cause git ls-tree to appear out of sync.

Another way is possible if you're using tree 1.8.0 since it supports the --fromfile flag:

   --fromfile  Reads a directory listing from a file rather than the file-system.  Paths provided on the command
   line are files to read from rather than directories to search.  The dot (.)  directory  indicates  that  tree
   should read paths from standard input.

We could use git ls-tree to get all non-git-ignored files in a project, and pipe the output to tree.

Assuming we have a git repository, where ignored files are ignored in .gitignore:

git_repo
├── .gitignore
├── bar
│   ├── b.txt
│   └── ignored
├── foo
│   ├── a.txt
│   └── ignored
└── ignored

The following command:

git ls-tree -r --name-only HEAD | tree --fromfile

Gives:

.
├── .gitignore
├── bar
│   └── b.txt
└── foo
    └── a.txt

2 directories, 3 files

Or if you need a specific path:

git ls-tree -r --name-only HEAD:foo | tree --fromfile

Gives:

.
└── a.txt

0 directories, 1 file

Caveats

  • Beware that changes such as deleted or renamed files that haven't already been committed can cause git ls-tree to appear out of sync.

Another way is possible if you're using tree 1.8.0 since it supports the --fromfile flag:

   --fromfile  Reads a directory listing from a file rather than the file-system.  Paths provided on the command
   line are files to read from rather than directories to search.  The dot (.)  directory  indicates  that  tree
   should read paths from standard input.

We could use git ls-tree to get all non-git-ignored files in a project, and pipe the output to tree.

Assuming we have a git repository, where ignored files are ignored in .gitignore:

git_repo
├── .gitignore
├── bar
│   ├── b.txt
│   └── ignored
├── foo
│   ├── a.txt
│   └── ignored
└── ignored

The following command:

git ls-tree -r --name-only HEAD | tree --fromfile

Gives:

.
├── .gitignore
├── bar
│   └── b.txt
└── foo
    └── a.txt

2 directories, 3 files

Or if you need a specific path:

git ls-tree -r --name-only HEAD foo | tree --fromfile

Gives:

.
└── a.txt

0 directories, 1 file

Caveats

  • Beware that changes such as deleted or renamed files that haven't already been committed can cause git ls-tree to appear out of sync.
Minor grammar mistake
Source Link
Zephyro
  • 371
  • 3
  • 4

Another way is possible if you're using tree 1.8.0 since it supports the --fromfile flag:

   --fromfile  Reads a directory listing from a file rather than the file-system.  Paths provided on the command
   line are files to read from rather than directories to search.  The dot (.)  directory  indicates  that  tree
   should read paths from standard input.

We could use git ls-tree to get all non-git-ignored files in a project, and pipe the output to tree.

Assuming we have a git repository, where ignored files are ignored in .gitignore:

git_repo
├── .gitignore
├── bar
│   ├── b.txt
│   └── ignored
├── foo
│   ├── a.txt
│   └── ignored
└── ignored

The following command:

git ls-tree -r --name-only HEAD | tree --fromfile

Gives:

.
├── .gitignore
├── bar
│   └── b.txt
└── foo
    └── a.txt

2 directories, 3 files

Or with if you need a specific path:

git ls-tree -r --name-only HEAD:foo | tree --fromfile

Gives:

.
└── a.txt

0 directories, 1 file

Caveats

  • Beware that changes such as deleted or renamed files that haven't already been committed can cause git ls-tree to appear out of sync.

Another way is possible if you're using tree 1.8.0 since it supports the --fromfile flag:

   --fromfile  Reads a directory listing from a file rather than the file-system.  Paths provided on the command
   line are files to read from rather than directories to search.  The dot (.)  directory  indicates  that  tree
   should read paths from standard input.

We could use git ls-tree to get all non-git-ignored files in a project, and pipe the output to tree.

Assuming we have a git repository, where ignored files are ignored in .gitignore:

git_repo
├── .gitignore
├── bar
│   ├── b.txt
│   └── ignored
├── foo
│   ├── a.txt
│   └── ignored
└── ignored

The following command:

git ls-tree -r --name-only HEAD | tree --fromfile

Gives:

.
├── .gitignore
├── bar
│   └── b.txt
└── foo
    └── a.txt

2 directories, 3 files

Or with if you need a specific path:

git ls-tree -r --name-only HEAD:foo | tree --fromfile

Gives:

.
└── a.txt

0 directories, 1 file

Caveats

  • Beware that changes such as deleted or renamed files that haven't already been committed can cause git ls-tree to appear out of sync.

Another way is possible if you're using tree 1.8.0 since it supports the --fromfile flag:

   --fromfile  Reads a directory listing from a file rather than the file-system.  Paths provided on the command
   line are files to read from rather than directories to search.  The dot (.)  directory  indicates  that  tree
   should read paths from standard input.

We could use git ls-tree to get all non-git-ignored files in a project, and pipe the output to tree.

Assuming we have a git repository, where ignored files are ignored in .gitignore:

git_repo
├── .gitignore
├── bar
│   ├── b.txt
│   └── ignored
├── foo
│   ├── a.txt
│   └── ignored
└── ignored

The following command:

git ls-tree -r --name-only HEAD | tree --fromfile

Gives:

.
├── .gitignore
├── bar
│   └── b.txt
└── foo
    └── a.txt

2 directories, 3 files

Or if you need a specific path:

git ls-tree -r --name-only HEAD:foo | tree --fromfile

Gives:

.
└── a.txt

0 directories, 1 file

Caveats

  • Beware that changes such as deleted or renamed files that haven't already been committed can cause git ls-tree to appear out of sync.
Small grammar fix
Source Link
Zephyro
  • 371
  • 3
  • 4
Loading
Source Link
Zephyro
  • 371
  • 3
  • 4
Loading