Is there a maximum number of git stashes?
Is there a maximum number of git stashes, or can you have as many as you like?
I'm aware that
git stash list
doesn't li开发者_如何学编程st as many results as
git stash list --date=local
But does Linus Torvalds think that anyone with more than x stashes is an idiot who deserves to lose the old stashes?
There is no hard limit to stashes. Stashes are simply implemented using the reflog of a specially-named ref called stash
.
No, there's no limit. In fact, Git handles large numbers of stashes quite gracefully:
$ du -sh .git; \
> for i in {1..10000}; do echo $i > README; git stash -q; done; \
> git gc -q; du -sh .git; time git stash list | wc -l
8.5M .git
13M .git # space efficient
10000 # all there
real 0m0.212s # listing 10,000 entries
$ echo foo > README; time git stash -q; time git stash pop -q
real 0m0.159s # save still fast
real 0m0.146s # pop still fast
I didn't test more, but I'd assume it'll still work the same for 100,000 or a million. So yes, the number of stashes really is unlimited.
精彩评论