Initialize a new repository

The VersionControl_Git class represents your Git repository.

You should specified a path to repository to VersionControl_Git.

<?php
require_once 'VersionControl/Git.php';

// Specify a directory
$git = new VersionControl_Git('/path/to/repository');

Do you want to create new repository? It is easy.

First, create an instance of VersionControl_Git and pass a directory what you want to create new Git repository.

Next, call the VersionControl_Git::initRepository() method.

<?php
require_once 'VersionControl/Git.php';

// Specify a directory
$git = new VersionControl_Git('/path/to/repository');

// create new repository
$git->initRepository();

// If you want to create bare repository, pass true as the first argument
$git->initRepository(true);

Do you want to create clone repository? In this case, you can use the VersionControl_Git::createClone()

<?php
require_once 'VersionControl/Git.php';

// Specify a directory
$git = new VersionControl_Git('/path/to/repository');

// create new repository
$git->createClone('http://example.com/repository.git');

// If you want to create bare repository, pass true as the second argument
$git->createClone('http://example.com/repository.git'true);

Now, you've readied to use full futures of VersionControl_Git.

Tutorial (Previous) Getting commits (Next)
Last updated: Sat, 16 Feb 2019 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

There are no user contributed notes for this page.