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

Re: git checkout effect on ls-files --others, how to merge partially?

From
Sitaram Chamarty <sitaramc@gmail.com>
Date
Feb 7, 2009, 01:28 UTC
Message-ID
<slrngopotq.his.sitaramc@sitaramc.homelinux.net>
In-Reply-To
<loom.20090206T163626-457@post.gmane.org>
On 2009-02-06, Bisani  Alok <alok.bisani@credit-suisse.com> wrote:
>> git checkout branch -- filename
> This is exactly what I was looking for, thank you! I
> wonder why it is the checkout command which does this,
> rather than the pull/merge. What is the reason that we
> cannot pull/merge a specific file from a branch?

Pull is to pull commits between repos, not files between commits. (The special case of using "." as the repo is just that -- a special case; ignore it for now).

Merge is to merge commits within a repo.

Both operate on entire commits, and both *create* a new commit to record their action (ignore the --no-commit option in merge for now; that too is a special case IMO, and its purpose does not detract from the overall sense of what I am saying anyway)

What you want is an individual file in a commit. 'git show' is a good way of getting that, as is 'git cat-file blob' (by the way I prefer 'git cat-file -p'). For blob objects, all of them seem to do the same thing.

But all of them are geared to putting the file onto stdout, and you deal with it how you want. They're all basically just 'cat', with a couple of extra whiskers perhaps :-)

'git checkout' is meant to 'checkout a branch or paths to the working tree' -- as it says on the tin, which is what you want.

Sita
Previous: bisani
Message 4 of 4 in “git checkout effect on ls-files --others, how to merge partially?”
  1. Bisani, AlokFeb 6, 2009
  2. Sitaram ChamartyFeb 6, 2009
  3. bisaniFeb 6, 2009
  4. Sitaram ChamartyFeb 7, 2009

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.