Loading...
 
Skip to main content

History: Git clone Tiki

Source of version: 25 (current)

Copy to clipboard
New to Git? 
See here: ((Git)) 
or here: [https://git-scm.com/book/en/v2|Pro Git Book (CC ND SA 3.0) by Scott Chacon and Ben Straub]

The __clone__ operation creates a local repository by copying information from a source repository. In the standard behavior, git will bring the entire changes history from source repository to local repository. That means both source and local repository will have the same history at the clone moment.


!! Cloning Tiki

!!! The basics

The basic and short syntax is -+git clone <repository> [<directory>]+-, where the mandatory argument -+<repository>+- is the source repository path or URL and the optional argument -+[<directory>]+- is the directory name where git will create the local repository.

By default, the clone process creates a repository in a folder with the same name of source repository, so in this case, the folder for local repository will have the name __tiki__.

{CODE(caption=>Clone into tiki folder,colors=bash)}
git clone https://gitlab.com/tikiwiki/tiki.git
{CODE}

By passing a second argument to clone command, it is possible to define the name to the folder for the cloned repository, like the examples below. 

{CODE(caption=>Also clone into tiki folder,colors=bash)}
git clone https://gitlab.com/tikiwiki/tiki.git tiki
{CODE}

{CODE(caption=>Clone into tikiwiki folder,colors=bash)}
git clone https://gitlab.com/tikiwiki/tiki.git tikiwiki
{CODE}

{CODE(caption=>Clone into current folder,colors=bash)}
git clone https://gitlab.com/tikiwiki/tiki.git .
{CODE}

!!! Choosing a branch
By default, the clone operation creates a local repository having the current branch set to __master__. There is an option called -+ --branch +- to change this behavior. The examples below creates 5 clones, each one with a different branch set.

{CODE(caption=>Clone and set 30.x into tiki30 folder,colors=bash)}
git clone --branch=30.x https://gitlab.com/tikiwiki/tiki.git tiki30
{CODE}

{CODE(caption=>Clone and set 29.x into tiki29 folder,colors=bash)}
git clone --branch=29.x https://gitlab.com/tikiwiki/tiki.git tiki29
{CODE}

{CODE(caption=>Clone and set 27.x into tiki27 folder,colors=bash)}
git clone --branch=27.x https://gitlab.com/tikiwiki/tiki.git tiki27
{CODE}

{CODE(caption=>Clone and set 24.x into tiki24 folder,colors=bash)}
git clone --branch=24.x https://gitlab.com/tikiwiki/tiki.git tiki24
{CODE}

Please note that the examples above clone Tiki source repository with the entire history. 

~tc~Do not change the following heading since it's taken as a start marker from page 'Get Tiki' to include some text there form here~/tc~

!! Dealing with Tiki huge repository

After a decade of contributions, Tiki history sizes 3GB when decompressed locally. That is too big when several Tiki instances is needed. As of now, two approaches were tested to deal with this problem:

* Share git objects with other clones
** -+ ~np~ git clone --shared --reference=<local-repository> <repository> [<directory>] ~/np~  +-
* Trim history size
** -+ ~np~  git clone --depth=1 <repository> ~/np~ +-

For example to create a clone of branch 30 in  a folder named tiki30 ===''without''=== all the history, which is also called a ===''shallow clone''=== 

{CODE(caption=>Shallow clone and set 30.x into tiki30 folder,colors=bash)}
git clone --depth=1 --branch=30.x https://gitlab.com/tikiwiki/tiki.git tiki30
{CODE}

More examples:

{CODE(caption=>Shallow clone and set 27.x into tiki27 folder,colors=bash)}
git clone --depth=1 --branch=27.x https://gitlab.com/tikiwiki/tiki.git tiki27
{CODE}

{CODE(caption=>Shallow clone and set 24.x into current folder instead,colors=bash)}
git clone --depth=1 --branch=24.x https://gitlab.com/tikiwiki/tiki.git .
{CODE}

Use master (previously called trunk):

{CODE(caption=>Shallow clone and set master into current folder,colors=bash)}
git clone --depth=1 --branch=master https://gitlab.com/tikiwiki/tiki.git .
{CODE}

!!! Sharing git history
This is a good approach for developers needing to have the full Tiki history since it saves network bandwidth and disk space. Git is able to borrow information from other local clones when creating a new clone. This reduces the network usage while cloning and reduces disk usage of maintaining several Tiki instances.

Information sharing is set by using the option -+ ~np~--reference=<local-repository>~/np~ +- and the option -+ ~np~--shared~/np~ +-, where -+<local-repository>+- is another clone made before.

The first step is to create a standard Tiki clone, like the example below.

{CODE(caption=>Clone into tikiwiki folder,colors=bash)}
git clone https://gitlab.com/tikiwiki/tiki.git tikiwiki
{CODE}

Then, other clones can be created by borrowing the information from the clone above.

{CODE(caption=>Clone and set master into tikimaster folder,colors=bash)}
git clone --branch=master --reference=./tikiwiki --shared https://gitlab.com/tikiwiki/tiki.git tikimaster
{CODE}

{CODE(caption=>Clone and set 30.x into tiki30 folder,colors=bash)}
git clone --branch=30.x --reference=./tikiwiki --shared https://gitlab.com/tikiwiki/tiki.git tiki30
{CODE}

{CODE(caption=>Clone and set 27.x into tiki27 folder,colors=bash)}
git clone --branch=27.x --reference=./tikiwiki --shared https://gitlab.com/tikiwiki/tiki.git tiki27
{CODE}

{CODE(caption=>Clone and set 24.x into tiki24 folder,colors=bash)}
git clone --branch=24.x --reference=./tikiwiki --shared https://gitlab.com/tikiwiki/tiki.git tiki24
{CODE}

!!! Trimming git history
Another way to reduce disk and network usage is the -+ ~np~--depth=<n>~/np~ +-, where -+<n>+- is the number of history entries desired to bring. This approach may not be ideal for Tiki development since the change history is not available. But it is a good way to keep track of the file state when installing Tiki in a server.

{CODE(caption=>Clone into tiki30 folder with 1 commit in history,colors=bash)}
git clone --branch=30.x --depth=1 https://gitlab.com/tikiwiki/tiki.git tiki30
{CODE}

{CODE(caption=>Clone into tiki30 folder with 2 commits in history,colors=bash)}
git clone --branch=30.x --depth=2 https://gitlab.com/tikiwiki/tiki.git tiki30
{CODE}

For the examples above, just the last -+<n>+- commits of branch 30.x will be available on local repository. All other information about branches and tags will not exist on local repository.

It is possible to have a cloned repository with the last -+<n>+- commits of each branch available. This is done by passing -+ ~np~--no-single-branch~/np~ +- to clone command.

~tc~Do not change the following heading since it's taken as a stop marker from page 'Get Tiki' to include some text there form here~/tc~

!! Creating a workspace
This is just a suggestion on how to setup a workspace in a development environment. The paths below can be set up in Nginx, Apache or any other webserver.

{CODE(caption=>1. Create a base folder and change to it,colors=bash)}
mkdir "/var/www/html"
cd "/var/www/html"
{CODE}

{CODE(caption=>2. Create a standard tiki clone,colors=bash)}
git clone https://gitlab.com/tikiwiki/tiki.git tiki
{CODE}

{CODE(caption=>3. Create a clone per tiki instance, referencing the tiki folder,colors=bash)}
git clone --branch=30.x --shared --reference=./tiki https://gitlab.com/tikiwiki/tiki.git doc.tiki.org
git clone --branch=30.x --shared --reference=./tiki https://gitlab.com/tikiwiki/tiki.git dev.tiki.org
git clone --branch=30.x --shared --reference=./tiki https://gitlab.com/tikiwiki/tiki.git example.com
git clone --branch=master --shared --reference=./tiki https://gitlab.com/tikiwiki/tiki.git tikimaster.docker
git clone --branch=30.x --shared --reference=./tiki https://gitlab.com/tikiwiki/tiki.git tiki30.docker
git clone --branch=27.x --shared --reference=./tiki https://gitlab.com/tikiwiki/tiki.git tiki27.docker
git clone --branch=24.x --shared --reference=./tiki https://gitlab.com/tikiwiki/tiki.git tiki24.docker
{CODE}

After above commands, the working space should have this structure:

{CODE(colors=bash)}
/var/www/html/tiki
/var/www/html/doc.tiki.org
/var/www/html/dev.tiki.org
/var/www/html/example.com
/var/www/html/tikimaster.docker
/var/www/html/tiki30.docker
/var/www/html/tiki27.docker
/var/www/html/tiki24.docker
{CODE}

!! Reference

* https://git-scm.com/docs/git-clone
Show PHP error messages