gh-cp
is a GitHub CLI extension that allows you to easily copy files from a GitHub repository to a local destination. With gh-cp
, you can seamlessly download specific files or multiple files from a repository, optionally specifying a branch or commit to copy from.
- Copy files from a GitHub repository to a local destination
- Support for copying multiple files in a single command
- Option to specify a branch or commit to copy files from
- Read file paths from a file for bulk copying
- GitHub CLI (version 2.0.0 or later)
- A GitHub account with appropriate permissions to access the repository
To install the gh-cp
extension, follow these steps:
- Ensure that you have GitHub CLI installed on your system.
- Install the
gh-cp
extension using the following command:This command will clone thegh extension install MohamedElashri/gh-cp
gh-cp
repository to your local extensions directory and make it available as agh
command. - Verify the installation by running:
If the installation is successful, you should see the help message for the
gh cp --help
gh-cp
extension.
The basic syntax for using gh-cp
is as follows:
gh cp [OPTIONS] <repo> [<paths>...] [<dest>]
<repo>
: The repository in the format 'owner/repo'.<paths>...
: The paths to the files in the repository (separated by space).<dest>
: The local destination directory (optional, default: current directory).
-h
,--help
: Show the help message and exit.-f
,--file <path>
: Read file paths from a file (one path per line).-b
,--branch <name>
: Specify the branch to copy files from (default: main).-c
,--commit <hash>
: Specify the commit hash to copy files from.
- Copy a single file from a repository:
gh cp myuser/myrepo path/to/file.txt
- Copy multiple files from a repository to a specific local directory:
gh cp myuser/myrepo path/to/file1.txt path/to/file2.txt /local/directory
- Copy files specified in a file:
The
gh cp -f path_file.txt myuser/myrepo
path_file.txt
should contain file paths, one per line. - Copy files from a specific branch:
gh cp -b feature-branch myuser/myrepo path/to/file.txt
- Copy files from a specific commit:
gh cp -c a1b2c3d4 myuser/myrepo path/to/file.txt
Note: Make sure you have the necessary permissions to access the files in the repository.
Contributions to gh-cp
are welcome! If you encounter any issues, have suggestions for improvements, or would like to add new features, please open an issue or submit a pull request on the GitHub repository.
gh-cp
is open-source software licensed under the MIT License.