How to use Git for version control

Git is a version control tool which allows you to keep a track of changes to your project files, store backups in the cloud and makes the overall collaborative process much easier.

This guide will explain how to push Digital Assistant components to Github, however the process should be similar for other cloud version control providers. This guide will assume that you're already registered and are ready to use Github.

Creating a remote repository

First of all let's create a new repository for our component:

Creating a repository on Github

In the following screen, you should see the address of your newly created repository. Keep a note of the repository url as we'll need it in the next steps:

Repository address

Pushing Digital Assistant Components to Github

For the next steps you need to have Git installed on your computer. If you don't have Git yet, you can install it from here. For this guide we're going to use Git Bash command line interface, however you can use a graphical user interface if you wish to.

First of all let's find the component in our Digital Assistant installation directory.

Navigate to Web → SpacesLocal → Global → Components directory where you should see a list of existing components:

Component in the list

For this guide we're going to push 'template-video-card' component to our remote Github repository. In order to do so let's navigate to the component directory using Git Bash command line interface:

cd /c/Program Files/adenin Workplace/Web/SpacesLocal/Global/Components/template-video-card

You can simply drag and drop the folder to Git Bash to get its directory.

Generally, with Github or any other cloud version control system you have 2 repositories: a local and a remote repository. Both, local and remote repositories should be kept in-sync. Since, we already have a remote repository created we're going to create a local repository and connect it to our remote. We'll do that by typing the following commands into Git Bash:

  1. Initialize a new local repository:

    git init
  2. Add all the content in our directory to it:

    git add .
  3. 'Commit' all the content we just added:

    git commit -m 'message to indicate what you are committing'
  4. Connect our remote repository with our local one (use the url you received when creating the remote repository here):

    git remote add origin your_remote_repository_url
  5. Push the files, you 'committed' to the remote repository:

    git push origin master

Now, if you look at your remote repository you should see your files:

Pushed files in the remote repository