Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

In this tutorial, we’ll show you how you can integrate version control into your workflow.

As the name of this tutorial suggests we will be using Git. If you don’t have Git installed, you can follow this tutorial.

Table of Contents

Repository setup

This part of tutorial show you how to setup empty repository, add .gitignore to your repository and setup remote repository. If you have an existing repository, folllow How to setup existing repository tutorial below.

First step is to initialize our Git repository. Dump your project using CleverMaps Shell. Open command line and go to dump of your project. You can use cd \path\to\your\dumpDirectory\projectId. Now use git init command. This will initialize your local repository.

Code Block
languagenone
cd \path\to\your\dumpDirectory\projectId
git init

...

Add following lines to your .gitignore or download it below.

Code Block
languagenone
dumpMetadata.json
/data

View file
name.gitignore

Warning: You need to save file above as “.gitignore”.
Now add your gitignore to your repository. Run following commands to commit changes.

Code Block
languagenone
git add .gitignore
git commit -m "Added gitignore"

Setting remote repository

We recommend saving your changes to remote repository provided by GitHub, Bitbucket or some other hosting service.

You can then add your remote repository. Then push local changes to remote branch.

Code Block
languagenone
git remote add <remote_name> <remote_repo_url>
git push --set-upstream <remote_name> <branch_name>

You have finished setting up your git repository. You can check you remote repositories with git remote -v.

...

If you already have existing repository, you can clone it. Open command line and go to your dump directory eg. cd \path\to\your\dumpDirectory. Now use git clone <repo-url>. It will create new directory in your dump directory.

Code Block
languagenone
cd \path\to\your\dumpDirectory
git clone <repo-url>

Now you should have new directory in your dump directory.

Saving changes to the repository

Whenever you make changes to the project you should commit them. In this part we will show you steps to take.

  1. push your changes to CleverMaps with CleverMaps Shell - use addMetadata and pushProject. Do not commit unfinished work.

  2. open command line in your project repository and run git add .. This will add all the changes to be commited. (see git add). You can review added files with git status.

  3. commit your changes with git commit -m "<commit_message>". Use descriptive commit messages.

  4. push your changes with git push.

Restoring backup

This part of tutorial showcases how you can restore older version of CleverMaps project using Git.

...

Open your project repository in command line.

...

Code Block
languagenone
<user>@<device> /c/CleverMaps/Projects/<projectId> (master) $ git log
commit 10e67edb0bedea12a422544cf6a49981aacab4f1 (HEAD -> master, origin/master)
Author: Your Name <you@example.com>
Date:   Fri Jul 29 15:12:53 2022 +0200

    removed average transaction, adjusted dashboard

commit 790a5d85b1d3fcd14e55d382adf7f017d3dc8bc4
Author: Your Name <you@example.com>
Date:   Fri Jul 29 15:01:54 2022 +0200

    Changed layout of dashboard

commit 8e0ac60fa0c7c9bcd4a0e12bfeb94eee77a9b3dd
Author: Your Name <you@example.com>
Date:   Fri Jul 29 14:59:28 2022 +0200

    Imported First project

commit 5faaed4143dda2016e93ef50fc44e1adfb995555
Author: Your Name <you@example.com>
Date:   Fri Jul 29 14:58:53 2022 +0200

    Added gitignore

...

Code Block
languagenone
<user>@<device> /c/CleverMaps/Projects/<projectId> (master) $ git checkout 790a5d85b1d3fcd14e55d382adf7f017d3dc8bc4
Note: switching to '790a5d85b1d3fcd14e55d382adf7f017d3dc8bc4'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 790a5d8 Changed layout of dashboard

<user>@<device> /c/CleverMaps/Projects/<projectId> ((790a5d8...)) $

...

Open CleverMaps Shell and login
Open project with openProject --project <project_id>
Now you can run status command. It will show you all the files that were changed between your checked out commit and current version.
You can also run diff. Diff will show changes in files.

...

Code Block
languagenone
daniel.valansky@secure.clevermaps.io/project:k5t8mf2a80tay2ng/dump:$ restoreMetadata
Restoring objects...
 
Adding all new objects to the project...
 
Added object average_transaction_metric.json
Added object average_transaction_indicator.json
 
2 new objects have been successfully uploaded to project k5t8mf2a80tay2ng
 
Uploading modified metadata objects to the project...
 
Uploaded object transactions_metric.json
Uploaded object business_overview_dashboard.json
 
Metadata of project k5t8mf2a80tay2ng successfully updated from dump
 
daniel.valansky@secure.clevermaps.io/project:k5t8mf2a80tay2ng/dump:$

...

Panel
panelIconId1f389
panelIcon:tada:
panelIconText🎉
bgColor#E3FCEF

The content you are trying to reach has been moved here: https://docs.clevermaps.io/docs/tutorial-11-project-versioning-with-git

We are proud to announce that we have launched a new documentation.

Please update your saved links and bookmarks to follow a new address docs.clevermaps.io.