From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?utf-8?Q?=C3=93scar_Fuentes?= Newsgroups: gmane.emacs.devel Subject: Re: Git question: when using branches, how does git treat working files when changing branches? Date: Wed, 28 Oct 2015 23:59:03 +0100 Message-ID: <87vb9qd2h4.fsf@wanadoo.es> References: <20151028192017.GC2538@acm.fritz.box> <87k2q6wy8p.fsf@linaro.org> <20151028223252.GD2538@acm.fritz.box> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1446073187 6194 80.91.229.3 (28 Oct 2015 22:59:47 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 28 Oct 2015 22:59:47 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Oct 28 23:59:38 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZrZgs-0007AG-RI for ged-emacs-devel@m.gmane.org; Wed, 28 Oct 2015 23:59:34 +0100 Original-Received: from localhost ([::1]:41034 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrZgs-00010o-0J for ged-emacs-devel@m.gmane.org; Wed, 28 Oct 2015 18:59:34 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44719) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrZgg-00010j-58 for emacs-devel@gnu.org; Wed, 28 Oct 2015 18:59:23 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZrZgc-00035U-V2 for emacs-devel@gnu.org; Wed, 28 Oct 2015 18:59:22 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:58556) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrZgc-00035O-Nz for emacs-devel@gnu.org; Wed, 28 Oct 2015 18:59:18 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1ZrZgZ-0006t6-C2 for emacs-devel@gnu.org; Wed, 28 Oct 2015 23:59:15 +0100 Original-Received: from 157.red-81-44-103.dynamicip.rima-tde.net ([81.44.103.157]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 28 Oct 2015 23:59:15 +0100 Original-Received: from ofv by 157.red-81-44-103.dynamicip.rima-tde.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 28 Oct 2015 23:59:15 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 47 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 157.red-81-44-103.dynamicip.rima-tde.net User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) Cancel-Lock: sha1:DOLdo1B634U2LlYhq/Yi4x/2Pis= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:192834 Archived-At: Alan Mackenzie writes: Joining the emacs-devel git hot line... >> By default git will complain if changing branches would revert >> uncommitted changes. > > OK, I started with a test repository, with some changes in (which I saved > in a diff file). After listing the available branches, and chosing one > at random, I did > $ git checkout /origin/master > , and got some message or other about a detached head. Without doing > anything else I then switched back with > $ git checkout master. > > git status now reports that the working directory is "clean". So one of > these two operations has discarded my changes. This is hard to believe, so I tried your steps: oscar@qcore:~/dev/emacs/emacs$ git checkout /origin/master fatal: Could not switch to '/origin/': No such file or directory As you can see, your first command fails to complete. I requested this on a previous question of yours about git and I request it again: please post the *exact* commands and its output. Otherwise, claims like what you made above are dubious, at best. [snip] >> Well I usually do a stash/rebase/stash-pop cycle in magit. However you >> may want to look at the rebase.autostash option (since Git 2.6) > > The problem is that, according to David K, there's only one stash stack, > so it would be very inconvenient having to keep track of which entries in > this stack belong to which branches. David Kastrup also suggested to commit your changes before switching branches, I wonder why you ignored his advice. Over the years I used several VC systems (CVS and subversion, among others) and git is, by far, the one that makes things easier when you don't want to lose your changes, committed or not. Finally, I wholeheartedly recommend to give Magit a try. [snip]