Skip to content

Git Integration

Backendless file storage can also function as a git repository. This could be very convenient for deploying multiple files from the developer's computer with a single command. Git integration is disabled by default. To enable git for the file storage:

  1. Open Backendless Console
  2. Select your app/backend
  3. Click Manage and scroll down to the Enable .git support section
  4. Use the toggle to turn git integration on or off:
    git-support

When the git integration is turned on, all files present in or uploaded to the file storage are immediately committed to the repository. This integration is bi-directional. It means that any files committed into the git repository by the means of git, will also be copied into the file storage. When git integration is being turned off, the git repository is deleted with all the associated history (the files remain in the file storage).

With the git integration enabled, a new folder (. git) appears in the File Browser on the Files screen. The folder contains the files from the git repository. When a file is uploaded to file storage either via the Upload API or using the File Browser, it is automatically committed to the repository. Likewise, when a file is pushed into the repository, it becomes available and visible in the file storage. The same applies to editing and deleting files either in the Backendless Console or in git repository.

When git is enabled, the repository is available at the following address:

 https://gitv4.backendless.com/<application id>/.git

where:

Argument                Description
<application id> application ID available in Backendless Console at Manage > App Settings.

When the Backendless backend is configured with a custom domain name, the repository URL is:

 http://<custom domain name>/.git

The repository uses the same authentication as Backendless Console. That means all git commands must use the same developer email address and password as for logging in to Backendless Console.

It is important to note that any system level files created by git are also placed into the file storage (the .git directory). These files are accounted for when calculating the file space used by the app/backend.

Configuring Local Environment

You have no local files and there is a remote GIT repository

There are files in the Backendless storage and there are no files locally:

Clone existing repository:

mkdir /path/to/your/project  
cd /path/to/your/project  
git clone http://gitv4.backendless.com/<your application id>/.git  
cd <your application id>

Adding a file locally and pushing to Backendless git:

> echo "First file" >> file.txt  
> git add file.txt  
> git commit -m 'Initial commit with new file'  
> git push -u origin master

You have with an existing GIT project in your local environment

This applies when you already have a local git project. You also enabled git integration in Backendless and need to "integrate" your local git project with the git repository in Backendless.

> cd /path/to/my/repo  
> git remote add origin http://gitv4.backendless.com/<your application id>/.git  

# pushes the repo and its refs for the first time to Backendless git  
> git push -u origin --all   

# pushes any tags to Backendless git  
> git push -u origin --tags 

You have an existing FILE project in your local environment.

This applies when you have existing files locally and need to add them to the git repository you initialized in Backendless.

> cd /path/to/my/repo  
> git init  
> git remote add origin http://gitv4.backendless.com/<your application id>/.git  
> git pull -u origin master  
> git add *  
> git commit -m 'merge with existing project'  
> git push -u origin master