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

Re: How to git checkout a orgin(unstage) version file in another directoy?

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Feb 17, 2011, 10:34 UTC
Message-ID
<20110217103431.GA8308@elie>
In-Reply-To
<loom.20110217T074533-358@post.gmane.org>
Chunlin Zhang wrote:
> I am writing a script for git-gui's "Tools" menu to diff a file.
> I want to checkout an origin file in a tmp directory and use the diff tool.

Because you are writing a script, I'd suggest using one of the "low-level commands (plumbing)" listed in git(1). Because you are retrieving a file, it would be one of the "interrogation commands". And because it is a single file, I suppose this should be git cat-file, git unpack-file, or git archive.

For example,
	git cat-file blob HEAD:README
will print the contents of README in the HEAD commit.

Because I am curious: what exactly would your script be used to do? Can the git diff-tree or git diff-files command help?

Previous: Michael J GruberNext: Chunlin Zhang
Message 9 of 11 in “How to git checkout a orgin(unstage) version file in another directoy?”
  1. Chunlin ZhangFeb 17, 2011
  2. Michael J GruberFeb 17, 2011
  3. Chunlin ZhangFeb 17, 2011
  4. Chunlin ZhangFeb 17, 2011
  5. Michael J GruberFeb 17, 2011
  6. Chunlin ZhangFeb 17, 2011
  7. Junio C HamanoFeb 17, 2011
  8. Michael J GruberFeb 18, 2011
  9. Jonathan NiederFeb 17, 2011
  10. Chunlin ZhangFeb 17, 2011
  11. Andreas SchwabFeb 17, 2011

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.