Re: checkout-cache -f: a better way?
flat view
From: Linus Torvalds <torvalds@osdl.org>
Date: 2016-06-15 22:41:58
On Fri, 20 May 2005, Jeff Garzik wrote:
Problem is, 'git-checkout-cache -q -f -a' really pounds the disk, and takes quite a while.
No. "git" is perfect, and "git-checkout-cache -f" already does exactly what you want.
Is there any way to avoid -f, while ensuring that the working directory truly represents the new branch?
You don't need to avoid -f, it already has the logic to avoid writing files that are already up-to-date. HOWEVER, your script is broken: git-read-tree $(cat .git/HEAD) && \ git-checkout-cache -q -f -a && \ git-update-cache --refresh you need to use the "-m" switch to git-read-tree to tell it to merge the index information from your previous tree with the new one. Also, don't do the "$(cat .git/HEAD)" thing any more, since modern git does this so much more nicely, and allows you to use your branch names directly. Finally, use the new "-u" flag to git-checkout-cache, which will update the cache as it goes along. In other words, those lines in your script should look like this: git-read-tree -m HEAD && git-checkout-cache -q -f -u -a and you'll be a lot happier. Linus