Day 11 Task: Advanced Git & GitHub for DevOps Engineers: Part-2

Day 11 Task: Advanced Git & GitHub for DevOps Engineers: Part-2

Hello DevOps comrades! 👋 Today, I continued my journey into the advanced realms of Git and GitHub. I got my hands dirty with Git Stash, Cherry-picking, and the art of resolving conflicts. Let's break down what I learned and did. 🚀

Git Stash: My Saviour in a Crunch 🛠️

Stashing is like hitting the pause button on my changes. Here's how I used it:

  1. Created a new branch with git checkout -b new-branch and made some edits.

  2. Ran git stash to store my changes temporarily, cleaning my working directory.

  3. Checked my stashes with git stash list to ensure my changes were safe.

I used git stash drop to remove a specific stash and git stash clear to clean the slate completely.

Cherry-Picking: Precision in Integration 🍒

Cherry-picking is my scalpel in Git surgery:

  1. Made commits on two branches.

  2. Used git cherry-pick <commit_hash> to transplant specific commits from one branch to another, ensuring only the changes I wanted were applied.

Resolving Conflicts: Keeping the Peace ✌️

Merging can sometimes lead to a tug-of-war. Here's how I kept the peace:

  1. Used git status to identify the conflicts.

  2. Ran git diff to examine the differences.

  3. Manually edited the files to resolve conflicts, then used git add to mark them as resolved.

Task-01: Stashing and Switching 🔄

  1. On my new-feature-branch, I made edits and ran git stash to store them.

  2. Switched to another-branch using git checkout, made commits there.

  3. Came back to new-feature-branch and used git stash pop to apply my stashed changes.

Task-02: Developing and Rebasing 🌲

On my development-branch:

  1. Added "After bug fixing, this is the new feature with minor alteration” and committed with “Added feature2.1 in development branch”.

  2. Continued with "This is the advancement of previous feature”, committed as “Added feature2.2 in development branch”.

  3. Finally, "Feature 2 is completed and ready for release", committed as “Feature2 completed”.

Then, I rebased these onto the production-branch derived from master to reflect all these messages.

Task-03: Cherry-Picking and Optimizing 🛠️

On the production-branch:

  1. Cherry-picked the "Added feature2.2 in development branch” commit.

  2. Added "Added few more changes to make it more optimized" after the existing content.

  3. Committed this as "Optimized the feature".


🔍 Reflections: The power of Git truly shines in complex workflows. Stashing changes, cherry-picking commits, and resolving conflicts are essential skills for any DevOps engineer. Every command I used today sharpened my Git prowess and prepared me for collaborative and fast-paced development environments. Can't wait to see what's next! #DevOps #GitMagic #EngineeringExcellence 🌟

Thank you for reading this Blog. Hope you learned something new today! If you found this blog helpful, please like, share, and follow me for more blog posts like this in the future.

You can connect with me at: https://www.linkedin.com/in/davendersingh/