A cli tool to download a directory from a git repo.
- Works on Linux and macOS
- Supports built in git credential store
Installing gitdir require golang tool chain.
There are two ways to install gitdir.
- Install with go tool chain
- Build from source
- Install with go tool chain.
go install github.com/thilinajayanath/gitdir@latest- Run the tool with a config file. An example config is shown below.
<go-path>/bin/gitdir -config config.yaml- Clone the repo and switch to the repo.
git clone https://github.com/thilinajayanath/gitdir.git
cd gitdir- Build the tool with go.
make build- Run the tool with a config file. An example config is shown below.
./bin/gitdir -config config.yamlConfiguration file is a yaml structure containing the following information.
- One or more git repo(s) from where the files are copied from under the
reposkey. - Each git repo has the following configurations.
- URL of the git repo (SSH or HTTPS).
- One of the following authentication methods.
none- If no authentication is required to access the gir repo (For example, for public git repos).ssh- For accessing a git repo using the ssh method. This require the ssh key path to be specified.credential-store- For accessing a git repo using an access token. Credentials are retrieved from the default locations specified here
- List of source directory of the repo, local destination path and the git revision.
An example configuration file is shown below.
repos:
- url: git@github.com:example-user/example.git
auth:
type: ssh
credentials:
key: /home/example/.ssh/id_rsa
directories:
- source: /
target: /tmp/example
revision: aaaabbbbccccddddeeeeffffgggghhhhiiiikkkk
- url: https://github.com/example-user/example.git
auth:
type: none
directories:
- source: /
target: /tmp/example
revision: aaaabbbbccccddddeeeeffffgggghhhhiiiikkkk
- url: https://github.com/example-user/private-repo.git
auth:
type: credential-store
directories:
- source: /
target: /tmp/example
revision: aaaabbbbccccddddeeeeffffgggghhhhiiiikkkk
- source: /test/data
target: /tmp/data
revision: aaaabbbbccccddddeeeeyyyygggghhhhiiiikkkk