Every time I checkout to a different branch on my local Git repo, I need to do the following:
1. git stash
2. git checkout branch_name
3. git stash pop stash@{0}
So I can get my working and staging directories with the checked out branch.
Is there a better and shorter way to do so? Whether its a trick/workaround or a direct built in command?
My way to make it easier is through ZSH alias as following:
myfunction() {
git stash
git checkout $1
git stash pop stash@{0}
}
alias gcost=myfunction