...
Open your project repository in command line.
Run
git checkout <commit_hash>
. Every commit made has a commit hash.
You can find commit hash that you want to restore withgit log
.
Example ofgit log
:Code Block language none <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
We can see in example 4 commits in master branch. The most recent commit has commit hash
10e67edb0bedea12a422544cf6a49981aacab4f1
. We would like to restore previous version with commit hash790a5d85b1d3fcd14e55d382adf7f017d3dc8bc4
.
So we rungit checkout 790a5d85b1d3fcd14e55d382adf7f017d3dc8bc4
.Code Block language none <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 withopenProject --project <project_id>
Now you can runstatus
command. It will show you all the files that were changed between your checked out commit and current version.
You can also rundiff
. Diff will show changes in files.Once you have recognized files you want to restore you have two options depending on what you want to restore:
RunrestoreMetadata
to restore all changes.
Or you runrestoreMetadata --objectName <object_name>
to restore one object.
Example ofrestoreMetadata
:Code Block language none 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:$
After you have restored files, you should commit new changesput
master
branch back in sync. Rungit switch -c <branch_name>
. This will create new branch from currently opened commit.
Now rungit add .
andgit commit -m "<commit_message>"
andgit push --set-upstream <remote_repository_name> <branch_name>
to create upstream branch and push changes.Now you should merge your new branch to your master branch. You can create merge request in web interface. (tutorial GitHub, BitBucket)
Run
git pull
to get latest changescheckout master --force
. Now open CleverMaps Shell and runfetch --force
to download latest changes from server. You can now commit changes to sync master with CleverMaps.