Home

Awesome

Git IPFS Remote Bridge

Git IPFS Remote Bridge is the set of programs written in Python 3 which allow Git user to clone, push, fetch, self-host or release Git repositories over IPFS decentralized data storage system.

Overview

Git IPFS Remote Bridge is written in Python 3. It provides the following programs:

Algorithms and logic here are partially inspired by Dropbox Git helper project.

Logo and Development Disclaimer

Logo

The program was developed under Remotization and Robotization Initiative at the Industrial Automation Lab of Elettra Sincrotrone Trieste by the members of the ICT/Scientific Computing Group. The logo created by @justeenduck based on the image generated by Kandinsky 2.2. The logo is published under Creative Commons Attribution-NoDerivatives 4.0 International (CC BY-ND 4.0) License.

Intended use cases

Features

Releases

The very special feature of the git-ipfs program is a possibility to order Git to prepare a release snapshot from the given commit or (usually) annotated tag. Executing git ipfs release command, the program performs the following steps:

  1. Orders Git via invocation of the git-archive program to prepare an archive containing snapshot of the repository state addressed by specified commit ID or tag name.
  2. Upload the created archive to IPFS network node obtaining an immutable entry, path-like IPFS link via prefix (/release.tar.gz by default) and associated CID.
  3. If IPNS public key is specified on the CLI, it will be associated with the obtained CID. Thus, the release snapshot will be published under IPNS entry key with all the protection features described above.

Limitations

Installation

Debian Packages

Debian packages for the program are now available in the Releases section of the repository.

Ubuntu PPA

The Debian packages are now accessible also using Ubuntu PPA. To install them, add the PPA repository to your system:

sudo su
echo 'deb https://ppa.launchpadcontent.net/twdragon/ipfs/ubuntu <DISTRO> main' >> /etc/apt/sources.list.d/ipfs
echo 'deb-src https://ppa.launchpadcontent.net/twdragon/ipfs/ubuntu <DISTRO> main' >> /etc/apt/sources.list.d/ipfs
apt update
apt install git-ipfs-remote-bridge
exit

replacing DISTRO with your Ubuntu distribution codename (jammy, noble, focal, and bionic are supported).

On the latest Ubuntu releases (jammy and later), the PPA could be added using a single command:

sudo add-apt-repository ppa:twdragon/ipfs
sudo apt update

Then just call apt:

sudo apt install git-ipfs-remote-bridge

Building a Package

Building your own Debian package requires debhelper script set installed on the system. Once it is done, the package can be built using just one command:

debuild

It will build the package and place the file into the uplevel directory. For further information, see Debhelper documentation.

Baremetal/Source Installation

As the program is written in Python and the Python interpreter is indicated in the same PATH context with Git, it is enough to copy the program executables somewhere to the directory also mentioned in this PATH context. For example, on most mainstream Linux distributions this could be done as the following:

sudo cp -v git-ipfs /usr/local/bin
sudo cp -v git-remote-ipfs /usr/local/bin
sudo chmod +x -v /usr/local/bin/git-ipfs /usr/local/bin/git-remote-ipfs

Prerequisites

Git IPFS Bridge uses requests, urllib, pathlib, and json modules. From them only requests is the third-party module out of the standard library. Please refer to your OS module installation system documentation to learn how to install the required modules and make them available for Python interpreter associated with Git.

To make the programs working, the functioning IPFS node with HTTP API entry point is needed. Please refer to https://docs.ipfs.tech to learn how to install Kubo or another implementation of IPFS node on your system.

Usage

For simplest case, the usage of the program starts from the following command invoked from the rood directory of the Git repository:

git ipfs install <URL>

where <URL> is an API URL addressing HTTP endpoint of the chosen IPFS node (for the local node likely http://127.0.0.1). This command will create IPFS infrastructure scripts and register them as Git hooks, then initialize a baremetal repository on IPFS as an entry point for IPFS data serializer. Afterwards, the origin remote address table will be created on Git and the obtained baremetal repository CID will be associated with the created remote. In case the origin remote was already exist before invocation of the command.

The repository with installed IPFS infrastructure can be used as any other Git repository. But when the push operation will be executed, Git will upload all data to IPFS and then tune up the remote links to comply with immutable CID changes. In case it is needed to uninstall IPFS infrastructure, it can be done with command:

git ipfs uninstall

All the previously defined remote settings, include URLs which were existing before installation of the IPFS infrastructure, will be restored.

Cloning

The program supports direct cloning of the repository from IPFS network. It can be done with command:

git ipfs clone <ID> <directory> <URL>

where:

Configuration

Configuration of the IPFS bridge is repository-specific. During the default installation process, the default configuration file is always installed. It complies with old INI key-value configuration format. The ordinary config file has the only section called IPFS. It is always named config being placed in .git/ipfs directory. This file contains both the regular setting intended to be adjusted by the git ipfs command, and advanced settings that should be adjusted manually.

Regular Settings

ParameterDefault valueDescription
URLhttp://127.0.0.1Host URL of IPFS API endpoint
Port5001API server's TCP port to connect
VersionPrefixapi/v0API URI prefix to stay compatible with future changes of the IPFS HTTP API
Timeout30.0HTTP timeout for I/O operatons. Increase this parameter if the repository is big or you see the timeout messages during push operations
UnpinOldfalseIf this flag is set, the bridge will instruct the IPFS node to unpin the previous state of the repository from the IPFS network. Useful for large repositories shared over IPFS only using tags
RepublishtrueAttends to change the addressed immutable CID if an IPNS node is specified as the remote address in the Git repository
IPNSTTLString24hString respresenting the duration of IPNS key ownership announcing after republishing
CIDVersion1CID version used to generate for the obtained immutable entries. Due the CIDs of version 0 are case-sensitive and incompatible with URI specs, it is recommended to use 0 value only if IPNS node is used in the remote
UserNameUsername to tell to HTTP API endpoint in case it is remote and Basic or Digest HTTP authentication is used. This option is commented by default
UserPasswordUsername to tell to HTTP API endpoint in case it is remote and Basic or Digest HTTP authentication is used. This option is commented by default

Advanced Settings

ParameterDefault valueDescription
IPFSChunkersize-65536Chunker routine name for being used to generate DHT data blocks for IPFS. Default is a linear chunker routine with 64KB block size

Commands and online help

The program works with the commands formulated like the following:

git ipfs <command> <mode> [options] <arguments>

Every command has its own online help. The -h key should be used to view the online help of the given command. In the help message, all available modes and options for the specified command will be described. Note that if the argument/option is not required, its name will be written within the brackets ([]). For example, for clone command the online help looks as the following:

git ipfs clone -h
usage: git-ipfs clone [-h] [-t TIMEOUT] [-r [REMOTE_NAME]] [-b [BRANCH]] [-n [USERNAME]] [-p [PASSWORD]] ipfs_id directory api_url [api_port]

positional arguments:
  ipfs_id               IPFS CID or IPNS peer name to use as remote ID
  directory             Relative directory to clone the repository in
  api_url               IPFS node API URL (API must be active to view the remote Git database!), default is http://127.0.0.1
  api_port              IPFS node API port (will be attached to URL) [5001]

options:
  -h, --help            show this help message and exit
  -t TIMEOUT, --timeout TIMEOUT
                        Network timeout for API communications, sec (float)
  -r [REMOTE_NAME], --remote-name [REMOTE_NAME]
                        Gives the remote name to make an IPFS remote, default is origin
  -b [BRANCH], --branch [BRANCH]
                        Gives name of the branch to checkout
  -n [USERNAME], --username [USERNAME]
                        HTTP authentication username
  -p [PASSWORD], --password [PASSWORD]
                        HTTP authentication password

Every working mode also has its own online help. If the user specifies -h key after mentioning the working mode, for example, git ipfs config manage -h, the online help for this mode will be printed.