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 4 clones, each one with a different branch set.
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
Clone and set 21.x into tiki21 folder
Copy to clipboard
git clone --branch=21.x https://gitlab.com/tikiwiki/tiki.git tiki21
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 27 in a folder named tiki27 without all the history, which is also called a shallow clone
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
More examples:
Shallow clone and set 24.x into tiki24 folder
Copy to clipboard
git clone --depth=1 --branch=24.x https://gitlab.com/tikiwiki/tiki.git tiki24
Shallow clone and set 21.x into current folder instead
Copy to clipboard
git clone --depth=1 --branch=21.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
That is a good approach to developers needing to have the full Tiki history, but without waste network bandwidth or disk space. Git is capable to borrow information from other local clone when creating a new clone. This reduces the network usage while cloning and reduces disk usage to maintain 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 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
Clone and set 18.x into tiki18 folder
Copy to clipboard
git clone --branch=18.x --reference=./tikiwiki --shared https://gitlab.com/tikiwiki/tiki.git tiki18
Trimming git history
Another available 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 so good to Tiki development, because the change history is not available. But it is good to keep track of file state when installing Tiki in a server.
Clone into tiki27 folder with 1 commit in history
Copy to clipboard
git clone --branch=27.x --depth=1 https://gitlab.com/tikiwiki/tiki.git tiki27
Clone into tiki27 folder with 2 commits in history
Copy to clipboard
git clone --branch=27.x --depth=2 https://gitlab.com/tikiwiki/tiki.git tiki27
On the examples above, just the last <n>
commits of branch 27.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=27.x --shared --reference=./tiki https://gitlab.com/tikiwiki/tiki.git doc.tiki.org
git clone --branch=27.x --shared --reference=./tiki https://gitlab.com/tikiwiki/tiki.git dev.tiki.org
git clone --branch=27.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=27.x --shared --reference=./tiki https://gitlab.com/tikiwiki/tiki.git tiki27.docker
git clone --branch=26.x --shared --reference=./tiki https://gitlab.com/tikiwiki/tiki.git tiki26.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/tiki27.docker
/var/www/html/tiki26.docker
/var/www/html/tiki24.docker
Reference
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 4 clones, each one with a different branch set.
{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}
{CODE(caption=>Clone and set 21.x into tiki21 folder,colors=bash)}
git clone --branch=21.x https://gitlab.com/tikiwiki/tiki.git tiki21
{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 27 in a folder named tiki27 ===''without''=== all the history, which is also called a ===''shallow clone''===
{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}
More examples:
{CODE(caption=>Shallow clone and set 24.x into tiki24 folder,colors=bash)}
git clone --depth=1 --branch=24.x https://gitlab.com/tikiwiki/tiki.git tiki24
{CODE}
{CODE(caption=>Shallow clone and set 21.x into current folder instead,colors=bash)}
git clone --depth=1 --branch=21.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
That is a good approach to developers needing to have the full Tiki history, but without waste network bandwidth or disk space. Git is capable to borrow information from other local clone when creating a new clone. This reduces the network usage while cloning and reduces disk usage to maintain 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 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}
{CODE(caption=>Clone and set 18.x into tiki18 folder,colors=bash)}
git clone --branch=18.x --reference=./tikiwiki --shared https://gitlab.com/tikiwiki/tiki.git tiki18
{CODE}
!!! Trimming git history
Another available 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 so good to Tiki development, because the change history is not available. But it is good to keep track of file state when installing Tiki in a server.
{CODE(caption=>Clone into tiki27 folder with 1 commit in history,colors=bash)}
git clone --branch=27.x --depth=1 https://gitlab.com/tikiwiki/tiki.git tiki27
{CODE}
{CODE(caption=>Clone into tiki27 folder with 2 commits in history,colors=bash)}
git clone --branch=27.x --depth=2 https://gitlab.com/tikiwiki/tiki.git tiki27
{CODE}
On the examples above, just the last -+<n>+- commits of branch 27.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=27.x --shared --reference=./tiki https://gitlab.com/tikiwiki/tiki.git doc.tiki.org
git clone --branch=27.x --shared --reference=./tiki https://gitlab.com/tikiwiki/tiki.git dev.tiki.org
git clone --branch=27.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=27.x --shared --reference=./tiki https://gitlab.com/tikiwiki/tiki.git tiki27.docker
git clone --branch=26.x --shared --reference=./tiki https://gitlab.com/tikiwiki/tiki.git tiki26.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/tiki27.docker
/var/www/html/tiki26.docker
/var/www/html/tiki24.docker
{CODE}
!! Reference
* https://git-scm.com/docs/git-clone