git clone

Clone a repository into a new directory

git clone [‑‑template=template_directory] [‑‑progress] [‑‑verbose] [‑‑quite] [‑‑local] [‑s] [‑‑no‑hardlinks] [‑‑no‑checkout] [‑‑bare] [‑‑mirror] [‑o name] [‑b name] [‑u upload‑pack] [‑‑reference repository] [‑‑dissociate] [‑‑separate‑git‑dir git dir] [‑‑depth depth] [‑‑[no‑]single‑branch] [‑‑recursive | ‑‑recurse‑submodules] [‑‑[no‑]shallow‑submodules] [‑‑jobs n]
                                                             [‑‑] repository [directory]

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

There seem to be several special case options that would be infrequently used.

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

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

--verbose
-v
Run verbosely.
--progress Progress is reported on standard error
--quiet
-q
Operate quietly. Progress is not reported to standard error
--recursive
--recurse-submodules
After the clone is created, initialize all submodules within, using their default settings.
Equivalent to running git submodule update --init --recursive immediately after the clone is finished.
Ignored if the cloned repository does not have a worktree/checkout (i.e. if any of --no-checkout, --bare, or --mirror is given)
--local
-l
When the from is on the local machine, bypass the "Git aware" transport mechanism and clone the repository by making a copy of HEAD and everything under objects and refs directories.
The files under .git/objects/ are hardlinked.

If the repository is a local path (for example, /path/to/repo), the default, and --local is a no-op. sic
If the repository is a URL, this flag is ignored
--no-local will override the default when /path/to/repo is given, using the Git transport .

--no-hardlinks Force cloning from a local repository to copy the files under the .git/objects directory . Used to make a back-up of a repository.
--reference repository If the reference repository is local, setup .git/objects/info/alternates to obtain objects from it. Using an existing repository as an alternate will require fewer objects to be copied from the repository being cloned.
see --shared option and --dissociate .
--dissociate Borrow the objects from reference repositories specified with --reference to reduce network transfer, and stop borrowing from them after a clone is made by making necessary local copies of borrowed objects. 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.
--no-checkout
-n
No checkout of HEAD is performed after the clone is complete.
--bare Make a bare repository. Do not of create directory and placing the administrative files in directory/.git, make the directory itself the $GIT_DIR. Implies no-checkout
The branch heads at the remote are copied directly to corresponding local branch heads, without mapping them to refs/remotes/origin/.
Neither remote-tracking branches nor the related configuration variables are created.
--mirror Implies --bare.
Maps local branches of the source to local branches of the target, and
maps refs (including remote-tracking branches, notes etc.) and
sets up a refspec configuration such that these refs are overwritten by a remote update in the target repository.
--origin name
-o name
Use name. Instead of the remote name origin to keep track of the upstream repository,
--branch name
-b name
Point to name branch Instead of the newly created HEAD to the branch pointed to by the cloned repository's HEAD, In a non-bare repository, this is the branch that will be checked out.
Can also take tags and detaches the HEAD at that commit in the resulting repository.
--upload-pack upload-pack
-u upload-pack
a non-default path for the command run on the other end. if the repository to clone from is accessed via ssh,
--template=template_directory Specify the directory from which templates will be used; (See the "TEMPLATE DIRECTORY" section of git-init(1).)
--config key=value
-c key=value
Set a configuration variable in the newly-created repository;
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) (for example, core.eol=true).
If multiple values are given for the same key, each value will be written to the config file.
This permits adding additional fetch refspecs to the origin remote.
--depth depth Create a shallow clone with a history truncated to the number of commits.
Implies --single-branch unless --no-single-branch is given to fetch the histories near the tips of all branches.
To clone submodules shallowly add --shallow-submodules.
--[no-]single-branch Clone only the history leading to the tip of a single branch, either specified by --branch or the primary branch remote's HEAD points at.
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-]shallow-submodules All submodules which are cloned will be shallow with a depth of 1.
--separate-git-dir=git dir Directory to place the cloned repository at then make a filesystem-agnostic Git symbolic link to there.
The result is repository can be separated from working tree.
-j n
--jobs n
The number of submodules fetched at the same time. Defaults to submodule.fetchJobs .

The default configuration creates references to the remote branch heads under refs/remotes/origin and by initializing remote.origin.url and remote.origin.fetch configuration variables.

GIT URLS

URLs include the transport protocol, the address of the remote server, and the path to the repository
Git supports ssh, git, http, and https

The native transport (i.e. git:// URL) does no authentication

implies --local option.

  • git://host.xz[:port]/path/to/repo.git/
  • http[s]://host.xz[:port]/path/to/repo.git/
  • ssh://[user@]host.xz[:port]/path/to/repo.git/
    An alternative scp-like syntax may also be used with the ssh protocol:
  • [user@]host.xz:path/to/repo.git/
    only recognized if there are no slashes before the first colon. This differentiates a local path that contains a colon. (ugly ed) For example the local path foo:bar could be specified as an absolute path or ./foo:bar to avoid being misinterpreted as an ssh url.

    The ssh and git protocols support ~username expansion:

  • ssh://[user@]host.xz[:port]/~[user]/path/to/repo.git/
  • git://host.xz[:port]/~[user]/path/to/repo.git/
  • [user@]host.xz:/~[user]/path/to/repo.git/
    For local repositories, also supported by Git natively, the following syntaxes may be used:
  • /path/to/repo.git/

    If there are a number of similarly-named remote repositories, use a different format for them create a configuration section of the form:

    [url "actual url base"]
    insteadOf = other url base
    For example, with this:
    [url "git://git.host.xz/"]
    insteadOf = host.xz:/path/to/
    insteadOf = work:
    a URL like "work:repo.git" or "host.xz:/path/to/repo.git" will be rewritten in any context that takes a URL to be "git://git.host.xz/repo.git".

    To rewrite URLs for push only, create a configuration section of the form:

    [url "actual url base"]
    pushInsteadOf = other url base
    For example, with this:
    [url "ssh://example.org/"]
    pushInsteadOf = git://example.org/
    a URL like "git://example.org/path/to/repo.git" will be rewritten to "ssh://example.org/path/to/repo.git" for pushes, but pulls will still use the original URL.

    EXAMPLES

  • Clone from upstream:
    $ git clone git://git.kernel.org/pub/scm/.../linux.git my-linux
    $ cd my-linux
    $ make
  • Make a local clone that borrows from the current directory, without checking things out:
    $ git clone -l -s -n . ../copy
    $ cd ../copy
    $ git show-branch
  • Clone from upstream while borrowing from an existing local directory:
    $ git clone --reference /git/linux.git \
    git://git.kernel.org/pub/scm/.../linux.git \
    my-linux
    $ cd my-linux
  • Create a bare repository to publish your changes to the public:
    $ git clone --bare -l /home/proj/.git /pub/scm/proj.git
  • Create a FORK
    git clone --verbose --progress --recursive https://github.com/ruuvi/ruuvi.firmware.c
    Cloning into 'ruuvi.firmware.c'...
    POST git-upload-pack (gzip 5241 to 2461 bytes)
    remote: Enumerating objects: 5350, done.
    remote: Counting objects: 100% (841/841), done.
    remote: Compressing objects: 100% (345/345), done.
    remote: Total 5350 (delta 571), reused 731 (delta 490), pack-reused 4509
    Receiving objects: 100% (5350/5350), 17.00 MiB | 18.89 MiB/s, done.
    Resolving deltas: 100% (3556/3556), done.
    Submodule 'ruuvi.boards.c'      (https://github.com/ruuvi/ruuvi.boards.c.git) registered for path 'src/ruuvi.boards.c'
    Submodule 'ruuvi.drivers.c'     (https://github.com/ruuvi/ruuvi.drivers.c.git) registered for path 'src/ruuvi.drivers.c'
    Submodule 'ruuvi.endpoints.c'   (https://github.com/ruuvi/ruuvi.endpoints.c) registered for path 'src/ruuvi.endpoints.c'
    Submodule 'ruuvi.libraries.c'   (https://github.com/ruuvi/ruuvi.libraries.c) registered for path 'src/ruuvi.libraries.c'
    Submodule 'src/semver.c'        (https://github.com/h2non/semver.c.git) registered for path 'src/semver'
    Cloning into 'ruuvi/firmware/3.30.3/pre/ruuvi.firmware.c/src/ruuvi.boards.c'...
    Cloning into 'ruuvi/firmware/3.30.3/pre/ruuvi.firmware.c/src/ruuvi.drivers.c'...
    Cloning into 'ruuvi/firmware/3.30.3/pre/ruuvi.firmware.c/src/ruuvi.endpoints.c'...
    Cloning into 'ruuvi/firmware/3.30.3/pre/ruuvi.firmware.c/src/ruuvi.libraries.c'...
    Cloning into 'ruuvi/firmware/3.30.3/pre/ruuvi.firmware.c/src/semver'...
    
    Submodule path 'src/ruuvi.boards.c':  checked out 'f574f46c656237b4f7565a71baa1d336049b70ee'
    Submodule path 'src/ruuvi.drivers.c': checked out 'be604c5f87ee362899ac4fa646bfd64d95823ab7'
    Submodule 'BME280_driver' (https://github.com/ruuvi/BME280_driver.git) 
                                           registered for path 'src/ruuvi.drivers.c/BME280_driver'
    Submodule 'STMems_Standard_C_drivers' (https://github.com/ojousima/STMems_Standard_C_drivers) 
                                            registered for path 'src/ruuvi.drivers.c/STMems_Standard_C_drivers'
    Submodule 'embedded-sht' (https://github.com/Sensirion/embedded-sht.git) 
                                           registered for path 'src/ruuvi.drivers.c/embedded-sht'
    Submodule 'ruuvi.dps310.c' (https://github.com/ruuvi/ruuvi.dps310.c) 
                                           registered for path 'src/ruuvi.drivers.c/ruuvi.dps310.c'
    Submodule 'nrf5_sdk15_platform/ruuvi.nrf_sdk15_3_overrides.c' (https://github.com/ruuvi/ruuvi.nrf_sdk15_3_overrides.c.git) 
                                           registered for path 'src/ruuvi.drivers.c/src/nrf5_sdk15_platform/ruuvi.nrf_sdk15_3_overrides.c'
    
    Cloning into 'ruuvi/firmware/3.30.3/pre/ruuvi.firmware.c/src/ruuvi.drivers.c/BME280_driver'...
    Cloning into 'ruuvi/firmware/3.30.3/pre/ruuvi.firmware.c/src/ruuvi.drivers.c/STMems_Standard_C_drivers'...
    Cloning into 'ruuvi/firmware/3.30.3/pre/ruuvi.firmware.c/src/ruuvi.drivers.c/embedded-sht'...
    Cloning into 'ruuvi/firmware/3.30.3/pre/ruuvi.firmware.c/src/ruuvi.drivers.c/ruuvi.dps310.c'...
    Cloning into 'ruuvi/firmware/3.30.3/pre/ruuvi.firmware.c/src/ruuvi.drivers.c/src/nrf5_sdk15_platform/ruuvi.nrf_sdk15_3_overrides.c'...
    
    Submodule path 'src/ruuvi.drivers.c/BME280_driver': checked out '69505ca262f44c3ddd6523733cd1f3a2e219bb69'
    Submodule path 'src/ruuvi.drivers.c/STMems_Standard_C_drivers': checked out '9a9a946c49c03062bb041036beef4194e37dbc6b'
    Submodule '_resources/STMems_Finite_State_Machine' (https://github.com/STMicroelectronics/STMems_Finite_State_Machine) 
                                        registered for path 'src/ruuvi.drivers.c/STMems_Standard_C_drivers/_resources/STMems_Finite_State_Machine'
    Submodule '_resources/STMems_Machine_Learning_Core' (https://github.com/STMicroelectronics/STMems_Machine_Learning_Core.git) 
                                        registered for path 'src/ruuvi.drivers.c/STMems_Standard_C_drivers/_resources/STMems_Machine_Learning_Core'
    
    Cloning into 'ruuvi/firmware/3.30.3/pre/ruuvi.firmware.c/src/ruuvi.drivers.c/STMems_Standard_C_drivers/_resources/STMems_Finite_State_Machine'...
    Cloning into 'ruuvi/firmware/3.30.3/pre/ruuvi.firmware.c/src/ruuvi.drivers.c/STMems_Standard_C_drivers/_resources/STMems_Machine_Learning_Core'...
    
    Submodule path 'src/ruuvi.drivers.c/STMems_Standard_C_drivers/_resources/STMems_Finite_State_Machine': checked out '50c975c4959d88fe63fffe936aba787e67cf32f2'
    Submodule path 'src/ruuvi.drivers.c/STMems_Standard_C_drivers/_resources/STMems_Machine_Learning_Core': checked out 'd7c64da7a62a6fc4311f9096641d9fe05090251b'
    Submodule path 'src/ruuvi.drivers.c/embedded-sht': checked out '9158f1c4ea13bc241793bd322cecfc45c7856d35'
    Submodule 'embedded-common' (https://github.com/Sensirion/embedded-common) registered for path 'src/ruuvi.drivers.c/embedded-sht/embedded-common'
    
    Cloning into 'ruuvi/firmware/3.30.3/pre/ruuvi.firmware.c/src/ruuvi.drivers.c/embedded-sht/embedded-common'...
    
    Submodule path 'src/ruuvi.drivers.c/embedded-sht/embedded-common': checked out '1ac7c72c895d230c6f1375865f3b7161ce6b665a'
    Submodule path 'src/ruuvi.drivers.c/ruuvi.dps310.c': checked out 'edacb9f15bf14b3379c9d1bcd72d35d6121eae34'
    Submodule path 'src/ruuvi.drivers.c/src/nrf5_sdk15_platform/ruuvi.nrf_sdk15_3_overrides.c': checked out '51c73f11e54e5b3de570bbef463c896ce8d8e564'
    Submodule path 'src/ruuvi.endpoints.c': checked out '2bf3c0ca74ce76923025b06d652c426578ae9dd3'
    Submodule path 'src/ruuvi.libraries.c': checked out '0d1ec7e9706530437665ccb0e65864a1be9d7cba'
    Submodule path 'src/semver': checked out 'bd1db234a68f305ed10268bd023df1ad672061d7'
    
    
    Results in the following directories (and more )
    /src
    
     application_config
     ruuvi.boards.c
     ruuvi.endpoints.c
    
     ruuvi.drivers.c
     ruuvi.drivers.c/embedded-sht, … 
     ruuvi.drivers.c/BME280_driver …
     ruuvi.drivers.c/STMems_Standard_C_drivers, …
     ruuvi.drivers.c/ruuvi.dps310.c
     ruuvi.drivers.c/test …
    
    /ruuvi.drivers.c/src
    /ruuvi.drivers.c/src/interfaces
    /ruuvi.drivers.c/src/integration_tests
    /ruuvi.drivers.c/src/nrf5_sdk15_platform
    /ruuvi.drivers.c/src/tasks
    
    
     ruuvi.libraries.c
     ruuvi.libraries.c/test …
    
     ruuvi.libraries.c/src
     ruuvi.libraries.c/src/libs
     ruuvi.libraries.c/src/integration_tests
    
     ruuvi.endpoints.c
     ruuvi.endpoints.c/test
     ruuvi.endpoints.c/src
    
     targets
     targets/ruuvitag_b
     targets/ruuvitag_b/armgcc
     targets/ruuvitag_b/ses
    
     semver
    
     system_tests
    
     test
     test/support