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

[PATCH] git-checkout: allow pathspec to recover lost working tree directory

From
Junio C Hamano <junkio@cox.net>
Date
Nov 15, 2006, 19:07 UTC
Message-ID
<7vbqn8msuw.fsf@assigned-by-dhcp.cox.net>

It is often wanted on the #git channel that this were to work to recover removed directory:

	rm -fr Documentation
	git checkout -- Documentation
	git checkout HEAD -- Documentation ;# alternatively
Now it does.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 * Back to fixing usability issues one at a time instead of
   throwing everything away with bathwater.
 git-checkout.sh |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/git-checkout.sh b/git-checkout.sh
index eb28b29..737abd0 100755
--- a/git-checkout.sh
+++ b/git-checkout.sh
@@ -112,7 +112,11 @@ Did you intend to checkout '$@' which ca
 		git-ls-tree --full-name -r "$new" "$@" |
 		git-update-index --index-info || exit $?
 	fi
-	git-checkout-index -f -u -- "$@"
+
+	# Make sure the request is about existing paths.
+	git-ls-files --error-unmatch -- "$@" >/dev/null || exit
+	git-ls-files -- "$@" |
+	git-checkout-index -f -u --stdin
 	exit $?
 else
 	# Make sure we did not fall back on $arg^{tree} codepath
-- 
1.4.4
Next: Anand Kumria
Message 1 of 4 in “git-checkout: allow pathspec to recover lost working tree directory”
  1. git-checkout: allow pathspec to recover lost working tree directoryJunio C Hamano, Nov 15, 2006
  2. Anand KumriaNov 16, 2006
  3. Junio C HamanoNov 16, 2006
  4. Petr BaudisNov 17, 2006

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.