Git and GitHub Advanced for DevOps

Atharv KarpeAtharv Karpe
3 min read

Mastering GitHub Advanced Concepts: My Challenge Experience

Last week, I shared my journey through GitHub Challenge, where I learned the fundamentals—initializing repositories, committing changes, branching strategies, and merging. This week, I leveled up by diving into Pull Requests (PRs), advanced merging techniques, and essential Git concepts like revert, rebase, reset, cherry-pick, and stash.

Here’s a deep dive into the tasks I completed and the key concepts I explored:


Task 1: Working with Pull Requests (PRs)

Concept:

A Pull Request (PR) is a collaborative workflow where developers propose changes, request reviews, and merge code into the main branch after approval.

What I Did:

  1. Forked a repository and cloned it locally.

  2. Created a feature branch (git checkout -b feature-branch).

  3. Made changes, committed them (git commit -m "Added a new feature"), and pushed the branch.

  4. Opened a PR on GitHub, requested a review, and merged it after approval.

Why It Matters:

PRs foster teamwork, improve code quality through reviews, and ensure smooth integration of changes.


Task 2: Undoing Changes – Reset & Revert

Concepts:

  • Reset: Moves the HEAD pointer to a previous commit (options: --soft, --mixed, --hard).

  • Revert: Safely undoes a commit by creating a new inverse commit.

What I Did:

  1. Accidentally committed incorrect changes (echo "Wrong code" >> wrong.txt).

  2. Tested different reset types:

    • git reset --soft (keeps changes staged).

    • git reset --mixed (unstages changes).

    • git reset --hard (discards all changes).

  3. Safely reverted a commit with git revert HEAD.

Why It Matters:

Knowing when to reset (local changes) vs. revert (shared commits) prevents data loss and maintains clean history.


Task 3: Stashing – Save Work Without Committing

Concept:

git stash temporarily shelves changes, allowing you to switch branches without committing incomplete work.

What I Did:

  1. Modified a file (temp.txt) without committing.

  2. Stashed changes (git stash).

  3. Switched branches and reapplied the stash (git stash pop).

Why It Matters:

Stashing is a lifesaver when you need to pause work and switch tasks without cluttering commits.


Task 4: Cherry-Picking – Selectively Apply Commits

Concept:

git cherry-pick copies a specific commit from one branch to another.

What I Did:

  1. Found a bug-fix commit (git log --oneline).

  2. Applied it to my branch (git cherry-pick <commit-hash>).

  3. Resolved conflicts (if any) and continued.

Why It Matters:

Cherry-picking is perfect for applying critical fixes without merging entire branches.


Task 5: Rebasing – Keeping a Clean Commit History

Concept:

git rebase integrates changes by rewriting history, avoiding unnecessary merge commits.

What I Did:

  1. Fetched latest changes (git fetch origin main).

  2. Rebased my branch (git rebase origin/main).

  3. Resolved conflicts (git rebase --continue).

Why It Matters:

Rebasing keeps commit history linear and clean, making it easier to track changes.


Key Takeaways

Pull Requests → Better collaboration & code reviews.
Reset/Revert → Safely undo mistakes.
Stash → Temporarily save work without commits.
Cherry-Pick → Apply specific fixes.
Rebase → Maintain a clean Git history.

My Experience & Final Thoughts

This challenge was an eye-opener—I now understand how these Git features enhance productivity in real-world development.

🔹 PRs made me appreciate structured code reviews.
🔹 Reset/Revert saved me from accidental errors.
🔹 Stashing helped me switch tasks efficiently.
🔹 Cherry-picking was a game-changer for selective fixes.
🔹 Rebasing kept my commit history neat.

These skills are essential for any developer looking to work efficiently in a team. Excited to apply them in real projects! 🚀


What’s Next?

I’m eager to explore Git workflows (like GitFlow) and CI/CD integrations next.

What Git concept do you find most useful? Share your thoughts in the comments! 👇

0
Subscribe to my newsletter

Read articles from Atharv Karpe directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Atharv Karpe
Atharv Karpe