Day 8 of My DevOps Journey: Pull Requests, Revert, Reset, Stash & Cherry-pick

Shorter day today, but the topics covered are ones you'll genuinely use all the time once working in a team on Git - pull requests, and a few ways to undo or rearrange work.
Pull Request (PR)
A pull request is a proposal to merge changes from one branch into another within a Git repository. It's not a Git command itself - it's a GitHub (and similar platforms) feature built on top of Git's branching model. Instead of merging directly, a PR lets you propose the merge, have it reviewed, discussed, and approved before it actually happens.
Also went through the process of actually raising a PR on GitHub - pushing a branch, opening a PR against the target branch, and merging it once ready.
git revert
git revert log_id
git revert undoes the changes introduced by a specific commit - but instead of deleting that commit from history, it creates a new commit that reverses its effect. This makes it a safe way to undo something, especially on a shared branch, since the original commit and its history remain intact.
If reverting causes conflicts (because later commits depend on the changes you're reversing), you resolve the conflicts manually and then run:
git revert --continue
to complete the revert.
git reset - use with caution
git reset log_id --soft
git reset moves the current branch pointer back to a specific commit, and depending on the flag used, handles the changes in between differently. There are three flags:
--soft - the changes from the commits being reset are moved back into the untracked + staged area. Nothing is lost; you can re-commit if you want.
--mixed - the changes are moved back to untracked only (unstaged). Still on disk, just not staged.
--hard - the changes are deleted entirely. This is the risky one - there's no undo unless you know the specific tricks (like
reflog) to recover it.
The key difference from revert: reset rewrites history. This is fine on a local branch nobody else has pulled, but dangerous on a shared branch, since it can create mismatches between your history and everyone else's. This is why it's generally something to use carefully and rarely, especially as a beginner.
Stashing
git stash
Sometimes you're in the middle of changes but need to switch branches or contexts without committing half-finished work. git stash saves your working directory's current state - including untracked changes - and reverts your working directory back to the last commit, so it looks "clean" temporarily.
git stash pop - restores the most recently stashed changes back into your working directory, and removes that entry from the stash list.
git stash list - shows all the stashes you currently have saved, in order.
git stash pop 1 - restores a specific stash by its index (in this case, the one at index 1), rather than just the most recent one.
This is genuinely useful for quickly switching tasks without losing in-progress work or committing something half-done.
Cherry-picking
git cherry-pick log_id
Cherry-picking lets you take one specific commit from another branch and apply it onto your current branch - without merging the entire branch. This is useful when you only need a single fix or feature from elsewhere, not the whole history of changes that branch contains.
What's next
A little more Git and GitHub left to cover before moving on.
GitHub - daily_devops/Day_08.md at main · NisargMakwana142/daily_devops
Comments
Join the discussionNo comments yet. Be the first to comment.




