What are git stashes really?
Git stashes are actually just commits in the local git repository.
I use git stashes a lot to back up my current un-commited code (git stash
, git stash apply
) so I can always revert back.
I see one problem with git stashes... They are only on your machine. There are actually no backups.
At the end of the day I do this..
git add .
git commit -m "stash"
git push origin [branch-name]
and in the morning...
git reset HEAD~1
I also do this when I want to switch branches and I want to save my current unfinished work. Therefore I know easily this "peice of work" belongs to this branch.
git add .
git commit -m "stash"
git push origin feature-y
git checkout feature-x
#do work
git checkout feature-y
git reset HEAD~1
Written by Kristian Lewis Jones
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Workflow
Authors
mklickman
24.96K
wjonthomas
9.185K
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#