Skip to content

Github cli extension to allow copying single files from repository without cloning

License

Notifications You must be signed in to change notification settings

MohamedElashri/gh-cp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

GitHub CLI Extension: gh-cp

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.

Features

  • 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

Requirements

  • GitHub CLI (version 2.0.0 or later)
  • A GitHub account with appropriate permissions to access the repository

Installation

To install the gh-cp extension, follow these steps:

  1. Ensure that you have GitHub CLI installed on your system.
  2. Install the gh-cp extension using the following command:
    gh extension install MohamedElashri/gh-cp
    
    This command will clone the gh-cp repository to your local extensions directory and make it available as a gh command.
  3. Verify the installation by running:
    gh cp --help
    
    If the installation is successful, you should see the help message for the gh-cp extension.

Usage

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).

Options

  • -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.

Examples

  1. Copy a single file from a repository:
    gh cp myuser/myrepo path/to/file.txt
    
  2. 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
    
  3. Copy files specified in a file:
    gh cp -f path_file.txt myuser/myrepo
    
    The path_file.txt should contain file paths, one per line.
  4. Copy files from a specific branch:
    gh cp -b feature-branch myuser/myrepo path/to/file.txt
    
  5. 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.

Contributing

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.

License

gh-cp is open-source software licensed under the MIT License.


About

Github cli extension to allow copying single files from repository without cloning

Topics

Resources

License

Stars

Watchers

Forks

Languages