Day 11 - Advance Git & GitHub for DevOps Engineers: Part-2 ๐
Unveiling Git Stash, Cherry-Pick, and Conflict Resolution ๐
Git Stash: Save Now, Apply Later! ๐ฆ๐ผ
Ever needed to switch branches without committing your changes? Enter Git Stash! It's like a coding pause button. Use git stash
to save your work, and git stash pop
to bring it back when you're ready. Easy peasy! ๐
Cherry-Pick: Selective Commit Magic! ๐โจ
Git Cherry-Pick lets you choose specific commits from one branch and apply them elsewhere. It's like cherry-picking the best commits for your masterpiece. ๐จ๐
Resolving Conflicts: The Peacekeeper Mode! ๐ค๐ง
Conflicts happen, but fear not! git status
shows conflicts, git diff
reveals differences, and git add
brings resolution. Conflict? Resolved! โ
๐ช
Hands-On Tasks: Git in Action! ๐ ๏ธ๐ป
Task 1: Stash and Pop, Like a Pro!
Create a new branch and make changes:
git checkout -b feature-branch # Make changes to your files
Use git stash to save changes:
git stash
Switch branches, make changes, and commit:
git checkout main # Make changes to your files and commit
Use git stash pop to bring back saved changes:
git checkout feature-branch git stash pop
Task 2: Feature Evolution with Rebase!
In version01.txt, add new lines and commit:
# Assuming version01.txt is already present git add version01.txt git commit -m "Add new lines in version01.txt"
Reflect commit messages in the Production branch using rebase:
git checkout production git pull origin production git rebase main # Resolve conflicts if any, and continue the rebase git rebase --continue # Repeat the above step if there are multiple conflicts
Task 3: Cherry-Pick Magic in Production!
Cherry-pick a commit from Development:
git checkout production git cherry-pick <commit-hash> # Replace <commit-hash> with the actual hash of the commit you want to cherry-pick # Resolve conflicts if any, and continue the cherry-pick git cherry-pick --continue # Repeat the above step if there are multiple conflicts
Add more lines, commit with an optimization twist:
# Make changes to your files git add . git commit -m "Add more lines with optimization"
Reflecting on Git Mastery! ๐๐ค
Day 11 delved into Git Stash, Cherry-Pick, and Conflict Resolution. Share your learnings, challenges! How's your Git journey evolving? Let's chat! ๐ฌ๐
Subscribe to my newsletter
Read articles from Nilkanth Mistry directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Nilkanth Mistry
Nilkanth Mistry
Embark on a 90-day DevOps journey with me as we tackle challenges, unravel complexities, and conquer the world of seamless software delivery. Join my Hashnode blog series where we'll explore hands-on DevOps scenarios, troubleshooting real-world issues, and mastering the art of efficient deployment. Let's embrace the challenges and elevate our DevOps expertise together! #DevOpsChallenges #HandsOnLearning #ContinuousImprovement