Skip to main content

Command Palette

Search for a command to run...

Day 10 — Advanced Git & GitHub for DevOps Engineers Part 2

Published
3 min readView as Markdown
Day 10 — Advanced Git & GitHub for DevOps Engineers Part 2
H

Harsh Rajotya is a technical blogger and a cloud DevOps engineer with a BE in Electronics and Computers from M.B.M. Engineering College, Jodhpur. He holds multiple certifications in AWS, Python, and RHCSA8, and is proficient in various cloud computing, infrastructure provisioning, containerization, CI/CD, and configuration management technologies and tools.

As a DevOps engineer at DevOpsFarm Inc, he deploys and manages end-to-end applications using Jenkins, Git, Terraform, Docker, and Kubernetes on AWS. He has experience in working with several AWS services, such as EC2, EBS, S3, VPC, autoscaling, and load balancing, and implements security policies using IAM, inline policies, and bucket policies. He also handles scheduled Cron jobs for snapshots and backups and is familiar with Ansible and Chef. He is passionate about learning new technologies and sharing his knowledge through technical blogging on Medium, where he has worked on projects involving deploying full-stack, Node.js, and MongoDB applications.

📋 Task 1: Branching, Committing, and Restoring

🌟 In this task, we’ll explore how to create a new branch 🌿, make changes with various messages 📝, and restore a file to an earlier version ⏪. Just follow these simple steps:

  1. 🚀 Create a new branch named “dev” from the main branch and verify the change using the command “git checkout dev”.
git checkout -b dev

2. 📝 Create a new text file named version01.txt and fill it with the following content:

"This is the first feature of our application."

3. 📂 Use the “git add” command followed by the file names to prepare the tracking changes. Then commit this change with the message “Added new feature.”

4. 📤 Push the dev branch to the remote repository using the command:

git push origin dev

5. 🔄 Make additional commits to the dev branch by updating the version01.txt file and commit this change with the message “Making the following changes: …”.

This is the bug fix in the development branch

6. 🔄 Perform this step two additional times, including the provided content, and commit each change with relevant messages.

This is gadbad code.

7. Again for adding feature4

This feature will goodbad everything from now.

8. Adding feature 5

9. 🔙 Revert the version01.txt file to a previous state with the content “This is the bug fix in the development branch.”

10. 📜 Using the “git log — oneline” command, find the <commit> information and identify the commit you want to reset to.

📋 Task 2: Branching, Merging, and Rebasing

In this task, we will explore the concepts of branches, merging, and rebasing. To get started, follow these steps:

  1. 🚀 Let’s merge the “dev” branch with the “main” branch. First, check the commits on the “dev” branch by using “git checkout dev” 👩‍💻. Then, switch back to the “main” branch and check its commits as well 🌿. Now, execute the “git merge dev” command to combine the commits and observe the results.

2. Now, execute the “git merge dev” command to combine the commits and observe the results.

3. 🔄 As a practice, perform a git rebase operation to see the difference it makes. Describe the differences you observe 🔄.

In this sequence of commands, developers start by checking out the “dev” branch in Git. They then create a new text file called “version01.txt” with specific content. The changes to this file are staged and committed with an appropriate commit message. After inspecting the commit history on the “dev” branch, they switch to the “main” branch and perform a rebase.

During the rebase, the commits from the “dev” branch are moved on top of the existing commits in the “main” branch, resulting in an updated, linear commit history on the “main” branch. This process demonstrates how branches interact, and how Git’s merge and rebase commands can be used to manage code development seamlessly.

Note: Git merge combines changes and preserves the original commit history, while Git rebase moves commits to create a cleaner, linear commit graph, making project tracking easier.

🎉 Conclusion 🎉

Congratulations on completing Day 10 of the #90DaysOfDevOps challenge! Today, we explored advanced Git techniques such as branching, merging, and reverting, essential for efficient collaboration and version control in software projects. Get ready for Day 11, where we’ll dive deeper into Git and GitHub for DevOps Engineers in the second part of this topic. Stay tuned for more exciting learning ahead! 🚀👩‍💻

More from this blog

90 Days of DevOps

30 posts