Working with Git in the Command Line

30 minutes
  • 5 Learning Objectives

About this Hands-on Lab

Git is a very popular distributed version control system. In this lab, you will be asked to perform basic Git-related tasks in the command line which includes installing Git, initializing a repository, adding and committing files, and creating and merging branches.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Install and Configure Git
  • Use the package manager to install the git package.
  • Update the Git user email setting to be cloud_user@mybusiness.com.
  • Update the Git username setting to be cloud_user.
Initialize the Git Repository
  • Create a directory in /home/cloud_user called alpha.
  • Change directories to /home/cloud_user/alpha.
  • Initialize the repository.
Add and Commit Files to the Git Repository
  • Create two files called artifact01 and artifact02.
  • Add the newly created files to the staging area.
  • Commit the files to the repository and include a message.
Create Branches of the Git Repository
  • Create a new branch called hot_fixes.
  • Create and checkout a branch called feature01.
  • Create a directory called feature01 that contains a file called manifest.txt.
  • Add and commit changes to the feature01 branch.
Merge a Branch with the Master
  • Checkout the master branch.
  • Merge the feature01 branch with the master.

Additional Resources

Scenario

You work in the IT operations department of a mid-sized company and are part of a group of employees that have been tasked with implementing a DevOps methodology across the organization. As part of this initiative, you will be reviewing Git as an alternative to your current source control system. This will involve installing Git on a local system that will be used for evaluation. Once installed, you'll initialize a repository in the /home/cloud_user/alpha directory. Then, you will test out the functionality by creating files and committing them to the repo, creating multiple branches, and, ultimately, merging a branch with the master branch.


Note:

  • All tasks should be performed as the cloud_user.
  • The cloud_user has been given sudo access to perform the required tasks.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?