clone

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 8, 2020 License: Apache-2.0 Imports: 2 Imported by: 6

Documentation

Overview

Package clone git-clone - Clone a repository into a new directory.

SYNOPSIS

Reference: https://git-scm.com/docs/git-clone

git clone [--template=<template_directory>]
				 [-l] [-s] [--no-hardlinks] [-q] [-n] [--bare] [--mirror]
				 [-o <name>] [-b <name>] [-u <upload-pack>] [--reference <repository>]
				 [--dissociate] [--separate-git-dir <git dir>]
				 [--depth <depth>] [--[no-]single-branch]
				 [--recurse-submodules] [--[no-]shallow-submodules]
				 [--jobs <n>] [--] <repository> [<directory>]

DESCRIPTION

Clones a repository into a newly created directory, creates remote-tracking branches for each branch in the cloned repository (visible using git branch -r), and creates and checks out an initial branch that is forked from the cloned repository’s currently active branch.

After the clone, a plain git fetch without arguments will update all the remote-tracking branches, and a git pull without arguments will in addition merge the remote master branch into the current master branch, if any (this is untrue when "--single-branch" is given; see below).

This default configuration is achieved by creating references to the remote branch heads under refs/remotes/origin and by initializing remote.origin.url and remote.origin.fetch configuration variables.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bare

func Bare(g *types.Cmd)

Bare Make a bare Git repository. That is, instead of creating <directory> and placing the administrative files in <directory>/.git, make the <directory> itself the $GIT_DIR. This obviously implies the -n because there is nowhere to check out the working tree. Also the branch heads at the remote are copied directly to corresponding local branch heads, without mapping them to refs/remotes/origin/. When this option is used, neither remote-tracking branches nor the related configuration variables are created. --bare

func Branch

func Branch(name string) func(*types.Cmd)

Branch Instead of pointing the newly created HEAD to the branch pointed to by the cloned repository’s HEAD, point to <name> branch instead. In a non-bare repository, this is the branch that will be checked out. --branch can also take tags and detaches the HEAD at that commit in the resulting repository. --branch <name>, -b <name>

func Config added in v0.12.0

func Config(key, value string) func(*types.Cmd)

Config Set a configuration variable in the newly-created repository; this takes effect immediately after the repository is initialized, but before the remote history is fetched or any files checked out. The key is in the same format as expected by git-config(1) (e.g., core.eol=true). If multiple values are given for the same key, each value will be written to the config file. This makes it safe, for example, to add additional fetch refspecs to the origin remote. --config <key>=<value>, -c <key>=<value>

func Depth

func Depth(value string) func(*types.Cmd)

Depth Create a shallow clone with a history truncated to the specified number of commits. Implies --single-branch unless --no-single-branch is given to fetch the histories near the tips of all branches. If you want to clone submodules shallowly, also pass --shallow-submodules. --depth <depth>

func Directory

func Directory(name string) func(*types.Cmd)

Directory The name of a new directory to clone into. The "humanish" part of the source repository is used if no directory is explicitly given (repo for /path/to/repo.git and foo for host.xz:foo/.git). Cloning into an existing directory is only allowed if the directory is empty. <directory>

func Dissociate

func Dissociate(g *types.Cmd)

Dissociate Borrow the objects from reference repositories specified with the --reference options only to reduce network transfer, and stop borrowing from them after a clone is made by making necessary local copies of borrowed objects. This option can also be used when cloning locally from a repository that already borrows objects from another repository—the new repository will borrow objects from the same repository, and this option can be used to stop the borrowing. --dissociate

func Jobs

func Jobs(n string) func(*types.Cmd)

Jobs The number of submodules fetched at the same time. Defaults to the submodule.fetchJobs option. -j <n>, --jobs <n>

func Local

func Local(g *types.Cmd)

Local When the repository to clone from is on a local machine, this flag bypasses the normal 'Git aware' transport mechanism and clones the repository by making a copy of HEAD and everything under objects and refs directories. The files under .git/objects/ directory are hardlinked to save space when possible. --local, -l

func Mirror

func Mirror(g *types.Cmd)

Mirror Set up a mirror of the source repository. This implies --bare. Compared to --bare, --mirror not only maps local branches of the source to local branches of the target, it maps all refs (including remote-tracking branches, notes etc.) and sets up a refspec configuration such that all these refs are overwritten by a git remote update in the target repository. --mirror

func NoCheckout

func NoCheckout(g *types.Cmd)

NoCheckout No checkout of HEAD is performed after the clone is complete. --no-checkout, -n

func NoHardlinks(g *types.Cmd)

NoHardlinks Force the cloning process from a repository on a local filesystem to copy the files under the .git/objects directory instead of using hardlinks. This may be desirable if you are trying to make a back-up of your repository. --no-hardlinks

func NoShallowSubmodules

func NoShallowSubmodules(g *types.Cmd)

NoShallowSubmodules All submodules which are cloned will be shallow with a depth of 1. --no-shallow-submodules

func NoSingleBranch

func NoSingleBranch(g *types.Cmd)

NoSingleBranch Clone only the history leading to the tip of a single branch, either specified by the --branch option or the primary branch remote’s HEAD points at. Further fetches into the resulting repository will only update the remote-tracking branch for the branch this option was used for the initial cloning. If the HEAD at the remote did not point at any branch when --single-branch clone was made, no remote-tracking branch is created. --no-single-branch

func Origin

func Origin(name string) func(*types.Cmd)

Origin Instead of using the remote name origin to keep track of the upstream repository, use <name>. --origin <name>, -o <name>

func Progress added in v0.12.0

func Progress(g *types.Cmd)

Progress Progress status is reported on the standard error stream by default when it is attached to a terminal, unless -q is specified. This flag forces progress status even if the standard error stream is not directed to a terminal. --progress

func Quiet

func Quiet(g *types.Cmd)

Quiet Operate quietly. Progress is not reported to the standard error stream. --quiet, -q

func RecurseSubmodules

func RecurseSubmodules(pathspec string) func(*types.Cmd)

RecurseSubmodules After the clone is created, initialize and clone submodules within based on the provided pathspec. If no pathspec is provided, all submodules are initialized and cloned. Submodules are initialized and cloned using their default settings. The resulting clone has submodule.active set to the provided pathspec, or '.' (meaning all submodules) if no pathspec is provided. This is equivalent to running git submodule update --init --recursive immediately after the clone is finished. This option is ignored if the cloned repository does not have a worktree/checkout (i.e. if any of --no-checkout/-n, --bare, or --mirror is given) --recurse-submodules[=<pathspec>]

func Repository

func Repository(url string) func(*types.Cmd)

Repository The (possibly remote) repository to clone from. See the URLS section below for more information on specifying repositories. <repository>

func SeparateGitDir

func SeparateGitDir(gitDir string) func(*types.Cmd)

SeparateGitDir Instead of placing the cloned repository where it is supposed to be, place the cloned repository at the specified directory, then make a filesystem-agnostic Git symbolic link to there. The result is Git repository can be separated from working tree. --separate-git-dir=<git dir>

func ShallowExclude added in v0.12.0

func ShallowExclude(revision string) func(*types.Cmd)

ShallowExclude Create a shallow clone with a history, excluding commits reachable from a specified remote branch or tag. This option can be specified multiple times. --shallow-exclude=<revision>

func ShallowSince added in v0.12.0

func ShallowSince(date string) func(*types.Cmd)

ShallowSince Create a shallow clone with a history after the specified time. --shallow-since=<date>

func ShallowSubmodules

func ShallowSubmodules(g *types.Cmd)

ShallowSubmodules All submodules which are cloned will be shallow with a depth of 1. --shallow-submodules

func Shared

func Shared(g *types.Cmd)

Shared When the repository to clone is on the local machine, instead of using hard links, automatically setup .git/objects/info/alternates to share the objects with the source repository. The resulting repository starts out without any object of its own. --shared, -s

func SingleBranch

func SingleBranch(g *types.Cmd)

SingleBranch Clone only the history leading to the tip of a single branch, either specified by the --branch option or the primary branch remote’s HEAD points at. Further fetches into the resulting repository will only update the remote-tracking branch for the branch this option was used for the initial cloning. If the HEAD at the remote did not point at any branch when --single-branch clone was made, no remote-tracking branch is created. --single-branch

func Template

func Template(templateDirectory string) func(*types.Cmd)

Template Specify the directory from which templates will be used; (See the 'TEMPLATE DIRECTORY' section of git-init(1).) --template=<template_directory>

func UploadPack

func UploadPack(value string) func(*types.Cmd)

UploadPack When given, and the repository to clone from is accessed via ssh, this specifies a non-default path for the command run on the other end. --upload-pack <upload-pack>, -u <upload-pack>

func Verbose added in v0.12.0

func Verbose(g *types.Cmd)

Verbose Run verbosely. Does not affect the reporting of progress status to the standard error stream. --verbose, -v

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL