In my Githubs repos documentation I want to represent a directory tree structure like this:
Here is a useful git alias
that works for me.
git config --global alias.tree '! git ls-tree --full-name --name-only -t -r HEAD | sed -e "s/[^-][^\/]*\// |/g" -e "s/|\([^ ]\)/|-- \1/"'
Here is the output of git tree
jonavon@XPS13:~/projects/roman-numerals$ git tree
.gitignore
pom.xml
src
|-- main
| |-- java
| | |-- com
| | | |-- foxguardsolutions
| | | | |-- jonavon
| | | | | |-- AbstractFile.java
| | | | | |-- roman
| | | | | | |-- Main.java
| | | | | | |-- Numeral.java
| | | | | | |-- RomanNumberInputFile.java
| | | | | | |-- RomanNumeralToDecimalEvaluator.java
|-- test
| |-- java
| | |-- com
| | | |-- foxguardsolutions
| | | | |-- jonavon
| | | | | |-- roman
| | | | | | |-- InterpretSteps.java
| | | | | | |-- RunCukesTest.java
| |-- resources
| | |-- com
| | | |-- foxguardsolutions
| | | | |-- jonavon
| | | | | |-- roman
| | | | | | |-- Interpret.feature
| | |-- sample-input.txt
The comparable tree
command
jonavon@XPS13:~/projects/roman-numerals$ tree -n
.
├── pom.xml
├── src
│ ├── main
│ │ └── java
│ │ └── com
│ │ └── foxguardsolutions
│ │ └── jonavon
│ │ ├── AbstractFile.java
│ │ └── roman
│ │ ├── Main.java
│ │ ├── Numeral.java
│ │ ├── RomanNumberInputFile.java
│ │ └── RomanNumeralToDecimalEvaluator.java
│ └── test
│ ├── java
│ │ └── com
│ │ └── foxguardsolutions
│ │ └── jonavon
│ │ └── roman
│ │ ├── InterpretSteps.java
│ │ └── RunCukesTest.java
│ └── resources
│ ├── com
│ │ └── foxguardsolutions
│ │ └── jonavon
│ │ └── roman
│ │ └── Interpret.feature
│ └── sample-input.txt
└── target
├── classes
│ └── com
│ └── foxguardsolutions
│ └── jonavon
│ ├── AbstractFile.class
│ └── roman
│ ├── Main.class
│ ├── Numeral.class
│ ├── RomanNumberInputFile.class
│ └── RomanNumeralToDecimalEvaluator.class
├── generated-sources
│ └── annotations
└── maven-status
└── maven-compiler-plugin
└── compile
└── default-compile
├── createdFiles.lst
└── inputFiles.lst
30 directories, 17 files
Clearly tree has better output, but I would like it to use my .gitignore file. So that my compiled content doesn't show