Objective:
The objective of this lab is to familiarize yourself with version control concepts, particularly branching, using Git.
Prerequisites:
- Install Git on your local machine if you haven’t already. You can download it from here.
- Have a basic understanding of Git commands such as
git init
,git add
,git checkout
,git commit
,git status
, andgit push
.
Instructions:
- Clone the Repository:
- Start by cloning the lab repository to your local machine using the following command:
git clone https://github.com/open-devsecops/topic-1-lab-reference-app
- Start by cloning the lab repository to your local machine using the following command:
- Navigate to the Repository Directory:
- Move into the directory of the cloned repository on your machine
cd <location_of_your_cloned_repo>
- Move into the directory of the cloned repository on your machine
- Create a New Branch:
- Create a new branch named
feature-branch-<your_name>
(or a unique identifier for your branch) using the following command:git checkout -b feature-branch-<your_name>
- Create a new branch named
- Make Changes:
- Make changes to the code or README file in the repository. This could be as simple as adding your name to a list or modifying a line of code.
- Stage and Commit Your Changes:
- Stage your changes using:
git add .
- Commit your changes with a descriptive message:
git commit -m "Changed README"
- Stage your changes using:
- Push Your Branch:
- Push your branch to the remote repository:
git push origin feature-branch
- Push your branch to the remote repository:
- Create a Pull Request:
- Navigate to the GitHub repository page.
- On the repo nav bar, click “Pull Requests.”
- On the right-hand side, click the green button titled “New Pull Request.”
- If it’s not already there, change base branch to “main” and change compare to the branch you made.
- Title it something meaningful, like “Added my name.”
- Click the green “Create pull request” button.
- Click the green “Merge pull request” button and “Confirm.”
- NOTE: Typically in a professional setting, this is a step that the owner of a project will take after reviewing the changes you made. But for this exercise, you will do both steps.