GitGitLab: Gitlab Git Plugin

GitGitLab integrates Gitlab in your git flow.

With GitGitlab, you can create projects, clone them and set them as remote source without leaving the command line.

Installation

sudo pip install gitgitlab

Example

$ git init
$ git touch 'readme.txt'
$ git add readme.txt
$ git commit -am 'initial commit'
$ git lab create -t my_project            # Creates project my_project and adds it as remote
  Project my_project created on Gitlab
$ git remotes
  gitlab

Command overview

git lab list
List your Gitlab projects
git lab create <project name>
Create a project on Gitlab
git lab track <project name>
Set this project as remote for your local repository.
git lab open <project name>
Open a Gitlab project page. If <project name> is omitted, uses the project on the ‘gitlab’ remote of the repository on the current directory.
git lab clone
Clone a Gitlab project.
git lab auth
Reset the Gitlab authorization token.

Listing your projects

git lab list lists all the projects that you own and their repository url.

Creating a new project

git lab create <project_name> creates a new private project on Gitlab.

git lab create <project_name> –track creates a new private project and sets it up as remote.

Setting up an existing project to track the local repository

git lab track <project_name> Adds a gitlab project as remote.

Opening the project page

git lab open <project_name> Opens the project page on the default browser.

Cloning a project

git lab clone <project_name> Clones the project.

Obtaining help

git lab help
Overview.
git lab <command> –help
Help for a specific command.

Using it from Python

To use gitgitlab from Python, import gitgitlab.client.

Using a custom Gitlab server

By default, gitgitlab uses https://gitlab.com as the Gitlab server url. If you are using your own Gitlab server, you can configure it using git config.

Configure your custom Gitlab server globally:

$ git config --global --replace-all gitlab.url <your server url>

Configure your custom Gitlab server only for the current repository:

$ git config --replace-all gitlab.url <your server url>

gitgitlab will try to connect to <your server url>/api/v3

See more:

Gitgitlab

Git interface

CLI interface for GitGitlab.

gitgitlab.cli.auth(*args, **opts)

Reset the authentication token.

gitgitlab.cli.clone(*args, **opts)

Clone a Gitlab project.

gitgitlab.cli.create(*args, **opts)

Create a Gitlab project and add it as remote.

gitgitlab.cli.get_gitlab()

Return a logged-in instance of the gitlab client.

Authenticate the client. If the authentication fails with an Unauthorized error, ask the user to provide the token again and retry.

gitgitlab.cli.git()

Git entry point.

gitgitlab.cli.list(*args, **opts)

List the projects owned by the user.

gitgitlab.cli.open(*args, **opts)

Open the project page on the default web browser.

gitgitlab.cli.track(*args, **opts)

Set a gitlab project as remote source.

Authentication

Gitlab client

Interface to Gitlab and Git.

exception gitgitlab.client.GitlabException

Gitlab error.

exception gitgitlab.client.NotFound

The item looked for was not found.

class gitgitlab.client.GitlabClient(url=None)

Simple Gitlab client.

clone(name, path=None)

Clone a Gitlab project.

Parameters:
  • name – Identifier name of the project to clone.
  • path – Path to clone to (deufaults to the project name).
create_project(name, wiki_enabled=False, public=False)

Create a project.

Parameters:
  • name – Name of the project.
  • wiki_enabled – Enable the wiki for this project.
  • public – Make the project public.
Return dict:

with the created project

get_gitlab_remote()

Return the gitlab remote of the repository in the current directory.

Raises NotFound:
 if the gitlab remote is not found.
get_project(name=None)

Return the project with the given name.

Parameters:name – Name of the project to return.
Raises NotFound:
 if the project does not exist.
get_project_name()

Return the name of the gitlab project that is tracking the repository in the current directory.

static get_project_name_from_url(url)

Extract the project name from the url and return it.

Parameters:url (str) – A project URL.
get_project_page(name=None)

Return the url of the page of a Gitlab project.

Parameters:name – Name of the project. If not provided, it will use the project name tracking the repository in the current directory.
Returns:Gitlab project page url.
get_projects()

Fetch the projects owned by the user.

Return list:of projects.
get_remote(name)

Return the remote with the given name of the repository in the current directory.

login(token)

Login to Gitlab.

Parameters:token – The user’s Gitlab private token.
track(project_name='gitlab', branch='master', remote_name='gitlab', no_push=False)

Set a gitlab repository as remote for the current git checkout.

Returns:The gitlab git remote.
url

Base URL of the GitLab server.

Indices and tables