Use Git to Make Changes to Code

45 minutes
  • 3 Learning Objectives

About this Hands-on Lab

Source Control Management (SCM) is an essential component of any DevOps pipeline. Git is the leading source control tool, and an understanding of its functionality is useful in a variety of roles. This activity will guide you through the basics of installing git and using a git workflow. After installing and configuring git, you will make a code change, commit it, push it to a remote git repository, and merge it using a pull request.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Get Git installed successfully

Git has to be installed successfully on the cloud server.

You can install git like this:

 sudo yum -y install git
Get your personal fork of the git repository cloned to the cloud server

You need to clone your personal fork of the sample git repository to the cloud server. Make sure you are in your home directory when performing the clone.

You can do so like this:

 cd ~/
 git clone git@github.com:&ltyour username&gt/cicd-pipeline-train-schedule-git.git
Push your commit to a new remote branch

Create a new branch, make a change in that branch, commit it, and push it to your personal fork on GitHub.com.

You can do this like so:

 git checkout -b myBranch
 &ltmake changes to source files&gt
 git add .
 git commit -m "&ltcommit message&gt"
 git push -u origin mybranch

Additional Resources

In this exercise, you are one of a team of developers. Your team uses feature branches to manage changes. You have been asked to make a change to the train-schedule app. Instead of the app's main page header reading "Train Schedule," the customer wants it to read “Find your train!” This text can be found in the project file views/index.jade, and you're going to have to change it.

Prerequisites:

  • A GitHub.com account

In order to push a change to the code, you will need to:

  • Install git
  • Configure git for ssh authentication with GitHub.com
  • Create a personal fork of the sample repository https://github.com/linuxacademy/cicd-pipeline-train-schedule-git
  • Clone your personal fork from GitHub
  • Create a feature branch to contain the change
  • Change the header text in views/index.jade from “Train Schedule” to “Find your train!”
  • Add the change in views/index.jade to the next commit
  • Commit the change
  • Push the change to the remote scm repository
  • Create a pull request to merge the feature branch into the master branch
  • Merge the pull request

Some useful links:

  • Full git documentation - https://git-scm.com/docs
  • Installation instructions for any system - https://git-scm.com/downloads
  • Setting up an ssh key on your system - https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/
  • Adding an ssh key to your GitHub.com account - https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/

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.

Get Started
Who’s going to be learning?

How many seats do you need?

  • $499 USD per seat per year
  • Billed Annually
  • Renews in 12 months

Ready to accelerate learning?

For over 25 licenses, a member of our sales team will walk you through a custom tailored solution for your business.


$2,495.00

Checkout
Sign In
Welcome Back!

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