From mboxrd@z Thu Jan 1 00:00:00 1970 From: "J.V." Subject: Re: problem switching branches Date: Fri, 01 Mar 2013 13:52:33 -0700 Message-ID: <51311511.9080601@gmail.com> References: <512D4087.5070504@gmail.com> <20130227051740.GB10976@sigill.intra.peff.net> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: "git@vger.kernel.org" To: unlisted-recipients:; (no To-header on input) X-From: git-owner@vger.kernel.org Fri Mar 01 21:53:02 2013 Return-path: Envelope-to: gcvg-git-2@plane.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UBWwv-0001c3-NA for gcvg-git-2@plane.gmane.org; Fri, 01 Mar 2013 21:53:02 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752180Ab3CAUwg (ORCPT ); Fri, 1 Mar 2013 15:52:36 -0500 Received: from mail-da0-f51.google.com ([209.85.210.51]:57144 "EHLO mail-da0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751140Ab3CAUwg (ORCPT ); Fri, 1 Mar 2013 15:52:36 -0500 Received: by mail-da0-f51.google.com with SMTP id z17so1564823dal.38 for ; Fri, 01 Mar 2013 12:52:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=qvmFLcTLrBK5Au8U1pFkuROxncAUFAbEBjh0zu//pn8=; b=zfqGyUINGmNvyuoULgDKFg6P3eGOhz74uHVU3DB0OyOy7jzAIC3fjw3VDCm32RhfkM 5eGLrz+I0WYVrslBolt5QYnzbYiEVINSdGP/tTyKqC+9IXsS4WzIV95zqqXpgrbpJowV oRqqAI67jtmpM4KqhKbGEcJv4W4BVk+xMWmXWhW6q25qDSOrL5Z/OOqlChyxcuP1EeBK V4R7feMJp3mgsldEKKs7hUZcDPBJ4ulex4JfQw7uQv+4MrBt1mFZxf1YAgnLm/8NQgGa 2ghXqBd22VVNExJxdWF59QYv1eQ1rROSGmp4Cexf7La8Bb3ls2Y26RtlVadpMLQASKA8 8gYA== X-Received: by 10.66.248.105 with SMTP id yl9mr20817360pac.183.1362171155534; Fri, 01 Mar 2013 12:52:35 -0800 (PST) Received: from [10.16.242.114] ([192.206.100.4]) by mx.google.com with ESMTPS id bi2sm14203629pab.18.2013.03.01.12.52.33 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 01 Mar 2013 12:52:34 -0800 (PST) User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130215 Thunderbird/17.0.3 In-Reply-To: <20130227051740.GB10976@sigill.intra.peff.net> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: On 2/26/2013 10:17 PM, Jeff King wrote: > On Tue, Feb 26, 2013 at 04:08:55PM -0700, J.V. wrote: > >> I was on my master branch, I then checked out a branch ( >> origin/somebranch ), made no updates >> but did a few git pulls on the branch over about a week; then made a >> small change to only a single file & committed & pushed. >> >> Now am trying to go back to my master branch and get: >> >> error: The following untracked working tree files would be >> overwritten by checkout: >> lib/derbyclient.jar >> Please move or remove them before you can switch branches. >> Aborting >> >> >> I did not put that jar file there (I edited a single config file), >> how do I now get back to my master branch? > Not knowing anything about your project, it's impossible to say for > sure, but this often happens with something like: > > 1. lib/derbyclient.jar used to be generated by your project's build > procedure This jar was put on the master branch last year; It does not exist in the branch that I am now on where I get the error message (I am on a branch that was created for a previous release). > > 2. You did a build of your project, generating the file in your > working tree. This jar is downloaded from the web and put there; we did not generate. > > 3. Meanwhile, somebody upstream added and commited lib/derbyclient.jar > directly in the repository. This might have been intentional (it > used to be a generated file, but now is included as source), or it > may have been an accident (mistaken use of `git add`). It was committed intentionally, last year, but does not exist in the branch that I am now on, but it is there. > > 4. You try to switch to the master branch with the new commits from > (3). Git sees that the copy of the file in your working tree would > be overwritten and lost (since it was never committed by you), so > aborts. > > If you are sure that the file in the working tree does not contain > anything interesting, you can use "git checkout -f master" to force the > overwrite. I will try this. > >> I do not want to muck up the branch that I am now on by deleting anything. >> Any ideas how this happened? > You won't hurt the branch you are on; you will just lose the contents in > the untracked working tree file. That's probably fine if it is a > generated file, as in the scenario I described above. We know that the > file is not included in the branch you are on (otherwise, it would not > be listed as untracked). And even if it were, you would only impact the > branch by committing the changes, not by changing the working tree. > >> Obviously someone put derbyclient.jar there, not sure, but it is >> supposed to be there so do not want to remove as advised. > It won't be removed; it will be overwritten with the version of the file > that is on "master". Which is probably what you want; you may want to > look at `git log master -- lib/derbyclient.jar` to see why it was added. > > -Peff