Git clone: Difference between revisions
(6 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
=Overview= | =Overview= | ||
'''git clone''' executes a repository [[Git_Concepts#Clone|cloning operation]]. The [[Git_clone#Clone_Mechanics|mechanics]] of the clone operation is described below. | |||
=Clone Mechanics= | =Clone Mechanics= | ||
This section refers to creation of [[Git_Concepts#Development_Repository|development repositories]], which come into existence as result of a cloning operation. The alternative is to create a [[Git_Concepts#Bare_Repository|bare repository]]. | This section refers to creation of [[Git_Concepts#Development_Repository|development repositories]], which come into existence as result of a [[Git_Concepts#Clone|cloning operation]]. The alternative is to create a [[Git_Concepts#Bare_Repository|bare repository]]. | ||
The local branches of the original repository, which are usually stored within .git/refs/heads directory of the original repository, become [[Git_Concepts#Tracking_Branch|tracking branches]] in the newly created repository. The tracking branches are stored under .git/refs/remotes/<''remote-name''> and they maintain the original names. In particular, the original repository's master branch becomes a tracking branch named .git/refs/remotes/<''remote-name''>/master. Within the clone repository, the new origin/master branch is initialized to point to the local master's HEAD. | The local branches of the original repository, which are usually stored within .git/refs/heads directory of the original repository, become [[Git_Concepts#Tracking_Branch|tracking branches]] in the newly created repository. The tracking branches are stored under .git/refs/remotes/<''remote-name''> and they maintain the original names. In particular, the original repository's master branch becomes a tracking branch named .git/refs/remotes/<''remote-name''>/master. Within the clone repository, the new origin/master branch is initialized to point to the local master's HEAD. | ||
Line 32: | Line 32: | ||
Changes the default name of the origin ([[Git_Concepts#.22origin.22|"origin"]]) of a cloned repository. | Changes the default name of the origin ([[Git_Concepts#.22origin.22|"origin"]]) of a cloned repository. | ||
==--depth== | |||
<font color=darkgray>TODO</font> | |||
=GitHub git clone= | |||
<syntaxhighlight lang='bash'> | |||
git clone git@github.com:/ovidiuf/shell-tools [./local-repository] | |||
</syntaxhighlight> |
Latest revision as of 21:11, 16 January 2024
Internal
Overview
git clone executes a repository cloning operation. The mechanics of the clone operation is described below.
Clone Mechanics
This section refers to creation of development repositories, which come into existence as result of a cloning operation. The alternative is to create a bare repository.
The local branches of the original repository, which are usually stored within .git/refs/heads directory of the original repository, become tracking branches in the newly created repository. The tracking branches are stored under .git/refs/remotes/<remote-name> and they maintain the original names. In particular, the original repository's master branch becomes a tracking branch named .git/refs/remotes/<remote-name>/master. Within the clone repository, the new origin/master branch is initialized to point to the local master's HEAD.
Remote tracking branches existent in the original repository at the time of the clone operation are not cloned - so the clone does not know what, if anything, the original is tracking.
Tags from the original repository are copied.
All objects that are reachable from the copied refs are copied. Since parents of commits are reachable from commits, the whole history is available in the cloned repository.
This command creates the working tree which is initially positioned on the master branch.
The following objects are not copied:
- hooks
- configuration files
- the reflog
- the stash
Options
--origin
Changes the default name of the origin ("origin") of a cloned repository.
--depth
TODO
GitHub git clone
git clone git@github.com:/ovidiuf/shell-tools [./local-repository]