npm-package

Copy file / folder from Git repo without cloning

Copy a file or folder from a Git repo instead of cloning, i.e. without a connection to the source

Changes in the original repo will not affect the copy of the file / folder and vice versa.

Helpful to reuse specific contents of another repo in a current one without mixing both repos.

hh lohmann <hh.lohmann@gmail.com>

Caution

Synopsis

  import { gitCopyFileFolder } from 'git-copy-file-folder'

  gitCopyFileFolder( sourceRepo, fileOrFolder)

  gitCopyFileFolder( sourceRepo, fileOrFolder, targetPath )

Parameters

sourceRepo

URL of the repo from which fileOrFolder should be copied

fileOrFolder

Name / path for the file / folder to be copied from the sourceRepo

targetPath

Optional: Existing path to which fileOrFolder should be copied to

Returns

Examples

  gitCopyFileFolder(
    'https://github.com/acmecorp/solve-all-problems',
    'secretsolutions'
  )

  gitCopyFileFolder(
    'https://github.com/acmecorp/solve-all-problems',
    'secretsolutions/solution-42.js',
    'ripped-stuff/acme/'
  )

Installation

Pick for your preferred package manager:

  npm i git-copy-file-folder
  pnpm i git-copy-file-folder
  bun i git-copy-file-folder
  # For Yarn you should double check docs for your and / or
  # current Yarn version, newer versions do not treat `i package_name`
  # as an alias for `add ...` and exclude global installations
  yarn add git-copy-file-folder

Details

Tests

Source Code

License

References

Git: clone sparse

Git: sparse-checkout

Endspacer: './markdown-assets/endspacer.png' missing - see https://hh-lohmann.github.io/html-endspacer
[top]