Stage 2.1 - Git

Return to Workshop

Stage 2 Git Basics

Estimated time to complete: 10 minutes

Stages

In Stage 2, we will discuss Git basics.

We will run through some of the commands and concepts to understand the power of Git.

Understanding the Git workflow is a key part of infrastructure automation.


Here are the requirements for Stage 2

Requirements

Here is a diagram of Stage 2. This shows all the technology we will be using in Stage 2.

It also defines the use cases we will be working on in Stage 2.

Diagram

Here is a summary of Stage 2

Stage 2 Summary

Use Git to pull down some code onto Server 1 and Server 2

Login to your Ubuntu Server 1 and Server 2 as a user

Open a terminal window

This will take some time. It is pulling down the Arista Lab Container Image along with other files

Run the following commands:

git clone https://gitlab.com/knorton3/network-automation.git
ls
cd network-automation/infra
git branch -m main master

This will create a new folder named network-automation

cloud_user@ed26757f4b2c:~$ git clone https://gitlab.com/knorton3/network-automation.git
Cloning into 'network-automation'...
remote: Enumerating objects: 214, done.
remote: Counting objects: 100% (157/157), done.
remote: Compressing objects: 100% (151/151), done.
remote: Total 214 (delta 58), reused 0 (delta 0), pack-reused 57
Receiving objects: 100% (214/214), 391.58 MiB | 6.09 MiB/s, done.
Resolving deltas: 100% (84/84), done.
cloud_user@ed26757f4b2c:~$ ls
Desktop  Documents  Downloads  Music  Pictures  Public  Templates  Videos  network-automation
cloud_user@ed26757f4b2c:~$ cd network-automation/infra
cloud_user@ed26757f4b2c:~/network-automation/infra$ git branch -m main master

Run the following commands to avoid logging into the repository with each pull and push request

git config --global credential.helper cache
git config --global lfs.cachecredentials true

Use Git to pull down some code onto your workstation

Create a folder named NAW

Open Visual Studio Code on your workstation

Click File → Open Folder and open the NAW folder

Trust the author of the folder if prompted

Open a terminal window, View → Terminal

This will take some time. It is pulling down the Arista Lab Container Image along with other files

This will create a new folder named network-automation

Run the following commands from the terminal:

git clone https://gitlab.com/knorton3/network-automation.git
cd network-automation/infra
git branch -m main master

Run the following commands to avoid logging into the repository with each pull and push request

git config --global credential.helper cache
git config --global lfs.cachecredentials true
Visual Studio Code

End Result

At this point, you will have pulled down all the code from the Git repository

Return to Workshop