Git clone: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 7: Line 7:
=Clone Mechanics=
=Clone Mechanics=


This section refers to creation of [[Git_Concepts#Development_Repository|development repositories]], which come into existence as result of a clone 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 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. 
 
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 [[Git_Concepts#Master_Branch|master branch]].
 
The following objects are not copied:
* hooks
* configuration files
* the reflog
* the stash


=Options=
=Options=

Revision as of 21:17, 19 March 2018

Internal

Overview

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.