Loading...
 
Skip to main content
(Cached)

Git clone Tiki

New to Git?
See here: Git
or here: 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.

Clone into tiki folder
Copy to clipboard
git clone https://gitlab.com/tikiwiki/tiki.git


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.

Also clone into tiki folder
Copy to clipboard
git clone https://gitlab.com/tikiwiki/tiki.git tiki

Clone into tikiwiki folder
Copy to clipboard
git clone https://gitlab.com/tikiwiki/tiki.git tikiwiki

Clone into current folder
Copy to clipboard
git clone https://gitlab.com/tikiwiki/tiki.git .

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.

Clone and set 30.x into tiki30 folder
Copy to clipboard
git clone --branch=30.x https://gitlab.com/tikiwiki/tiki.git tiki30

Clone and set 29.x into tiki29 folder
Copy to clipboard
git clone --branch=29.x https://gitlab.com/tikiwiki/tiki.git tiki29

Clone and set 27.x into tiki27 folder
Copy to clipboard
git clone --branch=27.x https://gitlab.com/tikiwiki/tiki.git tiki27

Clone and set 24.x into tiki24 folder
Copy to clipboard
git clone --branch=24.x https://gitlab.com/tikiwiki/tiki.git tiki24


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


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
    • git clone --shared --reference=<local-repository> <repository> [<directory>]
  • Trim history size
    • git clone --depth=1 <repository>


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

Shallow clone and set 30.x into tiki30 folder
Copy to clipboard
git clone --depth=1 --branch=30.x https://gitlab.com/tikiwiki/tiki.git tiki30


More examples:

Shallow clone and set 27.x into tiki27 folder
Copy to clipboard
git clone --depth=1 --branch=27.x https://gitlab.com/tikiwiki/tiki.git tiki27

Shallow clone and set 24.x into current folder instead
Copy to clipboard
git clone --depth=1 --branch=24.x https://gitlab.com/tikiwiki/tiki.git .


Use master (previously called trunk):

Shallow clone and set master into current folder
Copy to clipboard
git clone --depth=1 --branch=master https://gitlab.com/tikiwiki/tiki.git .

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 --reference=<local-repository> and the option --shared , where <local-repository> is another clone made before.

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

Clone into tikiwiki folder
Copy to clipboard
git clone https://gitlab.com/tikiwiki/tiki.git tikiwiki


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

Clone and set master into tikimaster folder
Copy to clipboard
git clone --branch=master --reference=./tikiwiki --shared https://gitlab.com/tikiwiki/tiki.git tikimaster

Clone and set 30.x into tiki30 folder
Copy to clipboard
git clone --branch=30.x --reference=./tikiwiki --shared https://gitlab.com/tikiwiki/tiki.git tiki30

Clone and set 27.x into tiki27 folder
Copy to clipboard
git clone --branch=27.x --reference=./tikiwiki --shared https://gitlab.com/tikiwiki/tiki.git tiki27

Clone and set 24.x into tiki24 folder
Copy to clipboard
git clone --branch=24.x --reference=./tikiwiki --shared https://gitlab.com/tikiwiki/tiki.git tiki24

Trimming git history

Another way to reduce disk and network usage is the --depth=<n> , 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.

Clone into tiki30 folder with 1 commit in history
Copy to clipboard
git clone --branch=30.x --depth=1 https://gitlab.com/tikiwiki/tiki.git tiki30

Clone into tiki30 folder with 2 commits in history
Copy to clipboard
git clone --branch=30.x --depth=2 https://gitlab.com/tikiwiki/tiki.git tiki30


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 --no-single-branch to clone command.


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.

1. Create a base folder and change to it
Copy to clipboard
mkdir "/var/www/html" cd "/var/www/html"

2. Create a standard tiki clone
Copy to clipboard
git clone https://gitlab.com/tikiwiki/tiki.git tiki

3. Create a clone per tiki instance, referencing the tiki folder
Copy to clipboard
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


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

Copy to clipboard
/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

Reference

Show PHP error messages