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 6, 2009, 13:28 UTC
Message-ID
<slrngooent.om3.sitaramc@sitaramc.homelinux.net>
In-Reply-To
<C5E2CAEE4A87D24DAB5334F62A72D1F43ADCBD@ELON17P32001A.csfb.cs-group.com>
On 2009-02-06, Bisani, Alok <alok.bisani@credit-suisse.com> wrote:
> 	I found a feature that was a bit surprising. Basically, a file
> exist on master as untracked (git-ls-files --others). It is git-add'ed
> on a branch. Now switching back to master, removes the file from
> master's working directory as well.

How would git know that you had such an untracked file in master? As far as git knows, at the point you switch back from branch to master, the file (a) is clean, exists/committed on branch and (b) does not exist on master. So it needs to be deleted.

If you really want to do this, you can "git stash" before switching to the branch and "git stash pop" when you come back to master.

> 	Is there a way to pull in changes from a branch but only limited
> to a file/files? I ended up doing a manual restore using git-cat-file
><branch>@{0}:/file. And checked in.
git checkout branch -- filename
Previous: Bisani, AlokNext: bisani
Message 2 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.