Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stashing without changing the index or the working tree

Tags:

git

git-stash

In Git from the Bottom Up John Wiegley suggest running a cronjob throughout the day that calls git stash followed by git stash apply. I appreciate the idea of having hourly (or even more frequent) snapshots of my work, but I'm afraid that the build could break if a file momentarily disappears or reverts to HEAD. Is there another way to accomplish the objective, without running this risk?

like image 842
user25643 Avatar asked Oct 07 '22 11:10

user25643


1 Answers

You could do something like:

git branch -f autosave $(git stash create)

This will force the branch autosave to update to a newly updated stash object. git stash create saves but doesn't touch your index and working tree. You can rely on the reflog of autosave to find previous versions just like stash does.

like image 87
CB Bailey Avatar answered Oct 12 '22 21:10

CB Bailey