Versions Compared

Key

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

...

  1. Open your project repository in command line.

  2. Run git checkout <commit_hash>. Every commit made has a commit hash.
    You can find commit hash that you want to restore with git log.

    Example of git log:

    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
    

    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 hash 790a5d85b1d3fcd14e55d382adf7f017d3dc8bc4.

    So we run git checkout 790a5d85b1d3fcd14e55d382adf7f017d3dc8bc4.

    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...)) $

  3. 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.

  4. Once you have recognized files you want to restore you have two options depending on what you want to restore:
    Run restoreMetadata to restore all changes.
    Or you run restoreMetadata --objectName <object_name> to restore one object.

    Example of restoreMetadata:

    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:$

  5. After you have restored files, you should commit new changesput master branch back in sync. Run git switch -c <branch_name>. This will create new branch from currently opened commit.
    Now run git add . and git commit -m "<commit_message>" and git push --set-upstream <remote_repository_name> <branch_name> to create upstream branch and push changes.

  6. Now you should merge your new branch to your master branch. You can create merge request in web interface. (tutorial GitHub, BitBucket)

  7. Run git pull to get latest changescheckout master --force. Now open CleverMaps Shell and run fetch --force to download latest changes from server. You can now commit changes to sync master with CleverMaps.