GH-CODESPACE-CP(1)
π¦ gh-codespace-cp β like, the vibe check
okay bestie, so the page header says GH-CODESPACE-CP(1) and this whole thing lives in the GitHub CLI manual β that's the manual name, iykyk. Welcome to copying files between your laptop and your codespace, but make it β¨aestheticβ¨.
π NAME
gh-codespace-cp β copy files between local and remote file systems. That's it, that's the whole gig π«Ά
β¨ SYNOPSIS
gh codespace cp [-e] [-r] [-- [<scp flags>...]] <sources>... <dest>
πΈ DESCRIPTION
The cp command copies files between the local and remote file systems. Literally just that. Iconic.
As with the UNIX cp command, the first argument specifies the source and the last specifies the destination; additional sources may be specified after the first, if the destination is a directory. So like, source first, dest last, extra sources in the middle β main character ordering π
The --recursive flag is required if any source is a directory. no skipping this one, bestie.
A remote: prefix on any file name argument indicates that it refers to the file system of the remote (Codespace) machine. It's resolved relative to the home directory of the remote user. cute and simple π
By default, remote file names are interpreted literally. With the --expand flag, each such argument is treated in the manner of scp, as a Bash expression to be evaluated on the remote machine, subject to expansion of tildes, braces, globs, environment variables, and backticks.
β οΈ Okay this part is important β for security, do not use this flag with arguments provided by untrusted users; see β¨https://lwn.net/Articles/835962/β© for discussion. like genuinely, don't do it. I'm being so serious rn π
By default, the cp command will create a public/private ssh key pair to authenticate with the codespace inside the ~/.ssh directory. It just... does that. slay π
π§ OPTIONS
-c,--codespace <string>β name of the codespace-e,--expandβ expand remote file names on remote shell-p,--profile <string>β name of the SSH profile to use-r,--recursiveβ recursively copy directories-R,--repo <string>β filter codespace selection by repository name (user/repo)--repo-owner <string>β filter codespace selection by repository owner (username or org)
π EXIT CODES
0β successful execution π1β error π2β command canceled π4β authentication required π
NOTE: specific commands may have additional exit codes. refer to the command's help for more information.
π EXAMPLE
$ gh codespace cp -e README.md 'remote:/workspaces/$RepositoryName/'
$ gh codespace cp -e 'remote:~/*.go' ./gofiles/
$ gh codespace cp -e 'remote:/workspaces/myproj/go.{mod,sum}' ./gofiles/
$ gh codespace cp -e -- -F ~/.ssh/codespaces_config 'remote:~/*.go' ./gofiles/
look at those examples go π the -e is doing so much work and I'm obsessed.
π SEE ALSO
gh-codespace(1) β go read that one too bestie, it's giving related content π
okay that's the whole page!! this lil beauty is from GitHub CLI v2.102.0, dated Oct 2026, and honestly? she ate. periodt π β¨
π¦ where this page comes from
- opensuse-leap 16.0: gh 2.102.0-bp160.1.1 Β· MIT
- opensuse-leap 16.0: gh 2.102.0-bp160.1.1 Β· MIT
- opensuse-leap 16.0: gh 2.102.0-bp160.1.1 Β· MIT
- opensuse-leap 16.0: gh 2.102.0-bp160.1.1 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms