Git Stash Guides
Git stash is used to record the current state of work, but reverts the context back to a clean slate before the changes were made. Learn more below.
This is a collection of top and trending guides written by the community on subjects related to Git Stash concepts. For all things git, check out the git tag! Please contribute more posts like this to help your fellow developer in need.
How to Git Stash Your Work [the Correct Way]
You need to work on that urgent bug. First, you want to save out unfinished work changes without committing them. This is where
git stash
comes as a savior:
How to stash a specific file or multiple files?
How to stash a specific file or multiple files?
Recover a lost Git stash in two steps
Fine, this code is merged, so let’s delete the related stashes. Done! And… hey… wasn’t this part of the feature supposed to be in the codebase? Is the stash I just deleted lost forever?
Discard File Changes by VSCode Instead of git stash
I have usually cleared a branch by using git stash. git stash is not for discarding unnecessary files but for storing the file changes for just a temporary moment.
How to abort the whole git stash process if a merge conflict has occurred in Git?
When popping out commits using the
git stash pop
command, you will have some merge conflicts sometimes, you can move to resolve those conflicts or abort the whole process.
don't use git stash pop
A git
stash
is a very powerful concept, it’s like Harry Potter’s Room of Requirement for your code, you throw it in here and you can get it back when you need it again in the future.
Need to stash untracked files? There is a way!
Stashing your changes is the best way to go. However, the default behavior of
git stash
is to stash only the tracked files. The untracked files will remain in your repo. Sometimes that is ok. You can have them there while you switch branches and deal with the emergency. But, in some occasions, their existence might interfere with other things (like changing the behavior of the software, or getting accidentally added to a commit).
Migrating repos from Atlassian Stash to Azure DevOps
Here is a guide on how I helped a cliend move from an internal, on-prem installation of Atlassian Stash to Azure DevOps using PowerShell and Azure CLI. Not sure if this is helpful for others, but it might in light of Atlassians lates announcment to discontinue their Server products by early 2024. I am not sure if the Stash system is part of this, but here is a guide anyhow.
Mastering Git Stash Workflow
Suppose you are working on a branch called
admin-dashboard
implementing ,well, an administrative dashboard. But you are not done yet, and the project manager wants a quickfix for the login implementation. Now you want to switch to thelogin
branch and fix the issue but don’t want to carry the changes you are doing on theadmin-dashboard
branch. Well this is where git stash comes in.
git stash - Store your uncommitted changes aside to work on it later
In this post, we'll be looking at the
git stash
command and its usage. We come across situations in our development work where we are in the middle of a task with quite a good amount of code changes and have to switch to some other task that has come on priority. Now, if the changes are somewhat complete then we can commit it and start with the other task but what if those changes are unfinished and far away from a meaningful commit, in that case instead of committing it we can make use of
git stash for dummy’s
Git stash for dummy’s or dirty & temporary commit
Happy Git Stash coding!