LinuxCommandLibrary

git-paste

Upload Git data to a pastebin service

TLDR

Send the patches between the current branch and its upstream to a pastebin using pastebinit

$ git paste
copy

Pass options to git format-patch in order to select a different set of commits (@^ selects the parent of HEAD, and so the currently checked out commit is sent)
$ git paste [@^]
copy

SYNOPSIS

git-paste [options] [file]

PARAMETERS

-d, --description <text>
    Sets a descriptive title or comment for the shared paste.

-l, --language <lang>
    Specifies the programming language for syntax highlighting, e.g., 'python' or 'javascript'.

-p, --public
    Makes the created paste publicly accessible on the service.

-s, --secret, --private
    Makes the created paste private or secret, accessible only via its unique URL.

-f, --filename <name>
    Assigns a specific filename to the content, especially useful when reading from standard input.

-u, --url-only
    Outputs only the URL of the created paste to standard output.

-c, --copy
    Copies the URL of the created paste to the system clipboard.

--no-browser
    Prevents the command from automatically opening the paste's URL in a web browser.

--version
    Displays the version information of the git-paste utility.

--help
    Shows a help message and exits.

DESCRIPTION

git-paste is a utility designed to streamline the process of sharing text, code snippets, or command output through Git-backed services, most commonly GitHub Gist. Instead of manually navigating web interfaces, users can pipe content directly into git-paste or specify a file. The command authenticates using existing Git credentials (e.g., SSH keys or personal access tokens) and then uploads the content, optionally with syntax highlighting based on file extension or explicit language declaration, and a specified description.

Upon successful upload, git-paste typically provides a URL to the newly created paste, enabling quick and easy sharing. This tool leverages the version control capabilities of Git to offer a persistent and organized way to share temporary information.

CAVEATS

  • Implementation Variability: git-paste is not a standard Git command, and its exact functionality, options, and underlying service support can vary significantly between different community-contributed implementations.
  • Authentication: It relies on correctly configured Git credentials (e.g., personal access tokens or SSH keys) for the target service (e.g., GitHub) to upload content.
  • Service Specificity: Most prevalent versions are tailored for GitHub Gists, meaning they might not directly support other pastebin services without modification.
  • Security: Users should be cautious when pasting sensitive information, especially if the paste is made public.

AUTHENTICATION DETAILS

git-paste typically relies on your existing Git configuration for authentication. For GitHub Gists, this means using either personal access tokens (PATs) configured with the necessary Gist scope or SSH keys registered with your GitHub account, which are used to interact with the Gist API or a private Git repository.

INPUT SOURCES

By default, if no file argument is provided, git-paste reads its content from standard input (stdin). This allows users to pipe the output of other commands directly into the tool for sharing, such as ls -l | git-paste.

SYNTAX HIGHLIGHTING INFERENCE

Many implementations attempt to automatically determine the language for syntax highlighting. If a file is provided, the language is often inferred from its file extension. When reading from stdin, the user might need to explicitly specify the language using the --language option.

HISTORY

git-paste does not have an official release history as a standalone project. Instead, it emerged organically from the developer community's need for a quick, command-line way to share code snippets and console output, particularly leveraging services like GitHub Gist. Various independent scripts and tools have been developed over time, often named git-paste, gist, or similar, each offering slightly different features but sharing the core concept of piping content to a Git-backed paste service. Its development is driven by community contributions and specific user requirements rather than a centralized project.

SEE ALSO

git(1): The distributed version control system that git-paste leverages., gist(1): A dedicated command-line tool for GitHub Gists, often serving a similar purpose., curl(1): A common tool used internally by git-paste for making HTTP requests to API endpoints.

Copied to clipboard