# 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 navigate to **Settings** application panel. There we click on **GIT** tab.

![Configuring GIT](https://2843146877-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-Lhtq66ZpqmjK4QshnVy%2F-LhtsMwLAK5nvyTOTeuU%2Fconfiguring-git.png?alt=media\&token=8502ddea-1185-4a97-abd0-c644f6fcbd2e)

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**

![Initializing local repository](https://2843146877-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-Lhtq66ZpqmjK4QshnVy%2F-Lhtttpq__GUKdC5rN7J%2Finitializing-local-git-repo.png?alt=media\&token=956d3ee5-18fb-497b-8b3a-35f5a9139cb7)

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://2843146877-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**

![Commit menu](https://2843146877-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-Lhtq66ZpqmjK4QshnVy%2F-Lhtv4G8_Kc-ssaU6vEv%2Fgit-commit.png?alt=media\&token=73e5553a-1373-44e0-a203-81b83616f677)

It opens **New Commit** modal window:

![Committing ver 1 ](https://2843146877-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://2843146877-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://2843146877-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**

![Git Checkout menu](https://2843146877-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-Lhtvbs37VkX2_2JOJVa%2F-LhtxR6d2N2PThDbDb2f%2Fcheckout-menu.png?alt=media\&token=f5402564-8fc4-45fc-9933-80d430fecdcf)

It opens the following modal window:

![Project local history](https://2843146877-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.

![Browsing version history](https://2843146877-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-Lhtvbs37VkX2_2JOJVa%2F-LhtxO7TnZ1-WECO808g%2Fsneaking.png?alt=media\&token=d0ec8eea-4a57-4394-bb66-de3a67a8d011)

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://2843146877-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://2843146877-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://2843146877-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://2843146877-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://2843146877-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LhuRJEEfkNYLBgDdZ76%2F-LhuTNCM3pSpA8CGFIrB%2Fconfiguring-remote.png?alt=media\&token=5a036484-d1c6-443a-9d59-0fcc357a9d8d)

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;

![Sync with remote menu](https://2843146877-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LhuRJEEfkNYLBgDdZ76%2F-LhuUbjWl7_YoZ3oAria%2Fgit-clone-menu.png?alt=media\&token=7ad5a49f-bdb3-457b-a9b5-f8c640a06c4e)

It opens the following modal window:

![Sync with remote modal window](https://2843146877-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LhuRJEEfkNYLBgDdZ76%2F-LhuUgVCH8WA52YXvovw%2Fsync-with-remote.png?alt=media\&token=ca940410-84e5-4bb1-898d-8ad0939574e5)

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

![Project artefacts on remote repository](https://2843146877-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://2843146877-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LhuRJEEfkNYLBgDdZ76%2F-LhuVE7zgGhJlMHl0K9B%2Fanother-user.png?alt=media\&token=98cb2e66-dec9-4e99-b6b7-94d83dd01902)

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

![Clone Project modal window](https://2843146877-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LhuRJEEfkNYLBgDdZ76%2F-LhuU_N7EMIe1-SlxTyQ%2Fclone-modal.png?alt=media\&token=305757b4-e3e5-4dc7-8253-03576fabb3a9)

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://2843146877-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://2843146877-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)
