# Version Control

Version control is a crucial part of development. Puppetry has an integrated [GIT client](https://git-scm.com/). Let's go together though a tutorial to examine how we can benefit of it.

## Working with Version History

First we take a look at how we can keep version history and navigate through it.

So we open a demo project and find **Project/Git** in the main menu.

![Git configuration](https://3461068122-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LuIhM1Vul7wpHkXM989%2F-LuJ2F-dRSN_Js9U6xmo%2Fgit2.png?alt=media\&token=0b4875c1-0866-4c71-bf48-7cb7aa3962e3)

Here we provide test author name and email. This information will be used to sign project version.&#x20;

After saving the changes we go in the main menu and click on **File / GIT / Initialize**

![File / Git menu](https://3461068122-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LuIhM1Vul7wpHkXM989%2F-LuJ2_hFrCSzc4u5zZhp%2Fgitfilemenu.png?alt=media\&token=67bea040-3f96-474c-8042-96d393f80f3e)

We've just created a local GIT repository for our project. There will be kept snapshots of all the committed versions. Let's see how it works.

We open a suite and jump to **Targets**. We add anew target `TEST_SELECTOR` with value `.ver1`

![](https://3461068122-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-Lhtq66ZpqmjK4QshnVy%2F-LhtuembW7Gb_40Jc9m8%2Ftest-selector-ver1.png?alt=media\&token=04907ae9-35fa-401b-9544-f34213eb6160)

Next in the main menu we click on **File / GIT / Commit**

It opens **New Commit** modal window:

![Committing ver 1 ](https://3461068122-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-Lhtq66ZpqmjK4QshnVy%2F-LhtvIFbH52v6sYav9qS%2Fcommit-ver1.png?alt=media\&token=472b4bd1-b430-4b9a-ba63-5144c3ce18b4)

We name the commit as **ver. 1** and click **Commit** button. Thus we get the first committed version.

Now we change the value of the target:

![](https://3461068122-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-Lhtvbs37VkX2_2JOJVa%2F-LhtvrrlMxxGiP6zBqPO%2Ftest-selector-ver2.png?alt=media\&token=3b49c087-715a-419f-92ea-e3b25111aaa7)

Then we commit the change (**File / GIT / Commit**).

![Committing ver 2](https://3461068122-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-Lhtvbs37VkX2_2JOJVa%2F-Lhtw5a_XXXcGjpBr4ey%2Fcommit-ver2.png?alt=media\&token=db061323-d781-4653-b528-f9152fa2340a)

Well, we have at least two versions of the project, so it makes some history.  Let's see what we really have. Click on  **File / GIT / Checkout**

It opens the following modal window:

![Project local history](https://3461068122-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-Lhtvbs37VkX2_2JOJVa%2F-LhtwtzUYGzdLVijxnxB%2Fgit-local-history.png?alt=media\&token=d33e3731-1a3e-4199-988e-90f9ac2b41c4)

Here we can see our previously committed changes.  Now we just to the **ver. 1** by clicking on **Checkout** link.

As we see `TEST_SELECTOR` has value `.ver1` of the previously saved version. As it says we are on a detached version. It's not the working one, so we can simply examine the contents and copy assets to paste into the head of history.

As we done we click on **Checkout master** button:&#x20;

![Checkout master button](https://3461068122-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-Lhtvbs37VkX2_2JOJVa%2F-Lhtxx78wpbwE282w2IG%2Fcheckout-btn.png?alt=media\&token=7e000770-9125-4110-bfe5-a7d5f4fa273e)

We've back to the working (last) version:

![](https://3461068122-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-Lhtvbs37VkX2_2JOJVa%2F-LhtybKD86BT0g81tD1D%2Fback-to-ver2.png?alt=media\&token=4609c727-efc4-440d-970c-4de3d6db36a6)

## Team Collaboration

Version control is especially good for collaboration. Let's imagine we have QA engineers Samwell Tarly and  Davos Seaworth. Sam is just committed a new version of the project and want to share it with Davos. For that guys need a remote repository. Let's take [Bitbucket](https://bitbucket.org) as service provider. So we register and create a new project:

![](https://3461068122-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LdyKSIjLn0DFAPpbWhT%2F-LdyKf7-heeT5RF-CKK-%2Fbitb1.PNG?alt=media\&token=98b7fd9b-9273-49a1-8920-0db7fcccca14)

That will bring us to the project page, which currently filled in with instruction to get started:

![Project page at Bitbucket](https://3461068122-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LhuRJEEfkNYLBgDdZ76%2F-LhuT-iHOEg9MMEBaNO-%2Fnew-bitbuncket-repo.png?alt=media\&token=6c079116-d5ca-440a-9110-94792ecff612)

Now we go back to Puppetry, open **Settings** application menu and jump to **GIT** tab. Next we scroll down to **Git Remote Repository** section:

![Configuring remote repository](https://3461068122-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LuIhM1Vul7wpHkXM989%2F-LuJ3CCE1P4wQZOk46W7%2Fgit-remote.png?alt=media\&token=6668a943-ef74-41a0-9dbd-6ed4aca52ce6)

Here we need to provide the remote repository URL (from Bitbucket) and user credentials.  Now we can synchronize our local repository to the remote one. Click **File / GIT / Sync**&#x20;

It opens the following modal window:

![Sync with remote modal window](https://3461068122-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LuIhM1Vul7wpHkXM989%2F-LuJ37HoEMu9m1ZUM5Km%2Fgit-sync.png?alt=media\&token=2c84c63c-94c5-4635-a139-6d72e1c1f07c)

As we confirm the synchronization we can refresh the page on Bitbucket:

![Project artefacts on remote repository](https://3461068122-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LhuRJEEfkNYLBgDdZ76%2F-LhuUqqScJ1f7SaeEf4n%2Fbitbucket-after-sync.png?alt=media\&token=6e2a9746-e89a-4e0e-9fd6-fb761d8b1113)

We can see that our project artifacts now are available there.&#x20;

Now Davos opens Puppetry on his machine and configure GIt:

![Davos' GIT configuration](https://3461068122-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LuIhM1Vul7wpHkXM989%2F-LuJ3Hiv8LRN5HMq-B-c%2Fgit-davos.png?alt=media\&token=129f9bc2-4c7e-49f4-ab1f-50b0e2926573)

He opens **File / GIT / Clone** in the main menu and gets the following modal window:

![Clone Project modal window](https://3461068122-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LuIhM1Vul7wpHkXM989%2F-LuJ3MXEy1Id-_v_nSKV%2Fgit-clone.png?alt=media\&token=061c70dd-295c-4f48-be8b-519d01b7d96a)

As he selects a destination and clicks on Clone, the version of Sam's project gets delivered to Davos' Puppetry.&#x20;

Well, let's really collaborate. Davos changes the target again:

![](https://3461068122-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LhuRJEEfkNYLBgDdZ76%2F-LhuVspeEbN0Qs7IKLvJ%2Fselector-v3.png?alt=media\&token=84a385a4-1bc0-4f2c-975a-d1cbb2b25bb1)

and commits the changes. Then he synchronizes with the remote repository (**File / Git / Sync with remote** ). Sam also synchronizes and sees the changes from Davos arrived:

![](https://3461068122-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LhuRJEEfkNYLBgDdZ76%2F-LhuWODH266CgMUK--xS%2Fselector-v3.png?alt=media\&token=09dee734-a14a-4ebe-b966-35a07cafc66a)
