From: Sitaram Chamarty Date: Fri, 06 Feb 2009 13:28:29 GMT Subject: Re: git checkout effect on ls-files --others, how to merge partially? Message-ID: In-Reply-To: On 2009-02-06, Bisani, Alok 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 >@{0}:/file. And checked in. git checkout branch -- filename