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:
Created a new branch with
git checkout -b new-branch
and made some edits.Ran
git stash
to store my changes temporarily, cleaning my working directory.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:
Made commits on two branches.
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:
Used
git status
to identify the conflicts.Ran
git diff
to examine the differences.Manually edited the files to resolve conflicts, then used
git add
to mark them as resolved.
Task-01: Stashing and Switching 🔄
On my
new-feature-branch
, I made edits and rangit stash
to store them.Switched to
another-branch
usinggit checkout
, made commits there.Came back to
new-feature-branch
and usedgit stash pop
to apply my stashed changes.
Task-02: Developing and Rebasing 🌲
On my development-branch
:
Added "After bug fixing, this is the new feature with minor alteration” and committed with “Added feature2.1 in development branch”.
Continued with "This is the advancement of previous feature”, committed as “Added feature2.2 in development branch”.
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
:
Cherry-picked the "Added feature2.2 in development branch” commit.
Added "Added few more changes to make it more optimized" after the existing content.
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/