git/list[1] front-page[2] threads[3] people[4] search[5] about
 

checkout-cache -f: a better way?

From
JGJeff Garzik <jgarzik@pobox.com>
Date
May 20, 2005, 21:05 UTC
Message-ID
<428E5102.60003@pobox.com>

Being a weirdo, I don't use cogito for kernel development, just git itself. I store branches in .git/refs/heads/ per the defacto standard, and use the attached script to switch the working directory from one branch to another.

Problem is, 'git-checkout-cache -q -f -a' really pounds the disk, and takes quite a while.

Is there any way to avoid -f, while ensuring that the working directory truly represents the new branch?

BitKeeper has a secret checkout arg '-S', which will leave files untouched if the mtime/size information is unchanged.

	Jeff
#!/bin/sh
if [ "x$1" != "x" ]
then
	if [ "$1" == "master" ]
	then
		( cd .git && rm -f HEAD && ln -s refs/heads/master HEAD )
	else
		if [ ! -f .git/refs/heads/$1 ]
		then
			echo Branch $1 not found.
			exit 1
		fi
		( cd .git && rm -f HEAD && ln -s refs/heads/$1 HEAD )
	fi
fi
git-read-tree $(cat .git/HEAD) && \
	git-checkout-cache -q -f -a && \
	git-update-cache --refresh
Next: Junio C Hamano
Message 1 of 11 in “checkout-cache -f: a better way?”
  1. Jeff GarzikMay 20, 2005
  2. Junio C HamanoMay 20, 2005
  3. Jeff GarzikMay 20, 2005
  4. Junio C HamanoMay 20, 2005
  5. Jeff GarzikMay 20, 2005
  6. Linus TorvaldsMay 21, 2005
  7. Jeff GarzikMay 21, 2005
  8. Linus TorvaldsMay 20, 2005
  9. Linus TorvaldsMay 20, 2005
  10. Jeff GarzikMay 20, 2005
  11. Junio C HamanoMay 20, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.