From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alex =?utf-8?Q?Benn=C3=A9e?= 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 20:10:14 +0000 Message-ID: <87k2q6wy8p.fsf@linaro.org> References: <20151028192017.GC2538@acm.fritz.box> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1446063063 5780 80.91.229.3 (28 Oct 2015 20:11:03 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 28 Oct 2015 20:11:03 +0000 (UTC) Cc: emacs-devel@gnu.org To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Oct 28 21:10:57 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 1ZrX3g-0000JG-8y for ged-emacs-devel@m.gmane.org; Wed, 28 Oct 2015 21:10:56 +0100 Original-Received: from localhost ([::1]:40533 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrX3f-0003i8-DH for ged-emacs-devel@m.gmane.org; Wed, 28 Oct 2015 16:10:55 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39680) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrX37-0003fS-MJ for emacs-devel@gnu.org; Wed, 28 Oct 2015 16:10:22 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZrX33-0003vm-6Z for emacs-devel@gnu.org; Wed, 28 Oct 2015 16:10:21 -0400 Original-Received: from mail-wi0-x231.google.com ([2a00:1450:400c:c05::231]:37223) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrX33-0003vV-0O for emacs-devel@gnu.org; Wed, 28 Oct 2015 16:10:17 -0400 Original-Received: by wicfv8 with SMTP id fv8so25982818wic.0 for ; Wed, 28 Oct 2015 13:10:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=references:user-agent:from:to:cc:subject:in-reply-to:date :message-id:mime-version:content-type:content-transfer-encoding; bh=bqmMIs4QhU/Iq2iBga69EKUYYeTZ/Q2qxpmwfqdJlI0=; b=06+cu55hHJ9qgQrKrh7jaEaLfx1CdsHUBAPd4Q/k8OTuZWphSwUsPwWXwx/GagecoO bp/Nezu3TQAZ46DnB63QzDdAuxggeAoGjyHCzTnnrBwzLRjRdlc3QpYCOat7K48pzCOC xNWBPdmYYbnoNqvgfIm33Rj6HyO7NX3ahfQqbKD3ZoKXbPCfGD3BMCq3y6TqSvaH88b3 TCxsW6X7YX2MR5nyEGafBNQhyzXwSNqB/itob5wI3ETZ/7R5Mx4wJCI3loTc5S9n6mzq cLeeuhrXmbA2yjb9EOk+IwLXUmnOld230XAjDqZrsp5sQsNg2av+JCG56Zx1sPnDR0wO wJxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:references:user-agent:from:to:cc:subject :in-reply-to:date:message-id:mime-version:content-type :content-transfer-encoding; bh=bqmMIs4QhU/Iq2iBga69EKUYYeTZ/Q2qxpmwfqdJlI0=; b=TTNLDwjAsBk2YU5Q/XsBhTxLGzExwe5icuYoxlNB63eS5Egr5Yh/+px7EsCZPse8YD azPvZrf+jBa/xx6cAnKln5g3hl0756fCYsLMsJFl3set3PH56BaUs20lyTctoYSF7E1q N6sM+FpC4X0IjmNycI0Vz2W0QbM9peFVQ294aoV9I0Dx9AQ40wlp79n8kvsgtiLGdMm8 k6e8brBl5o3mURZSq7849rfXMDKF9gyG/wI/VmAAjxInr9hjE9ZFcTM+PYVKQ5nRBBKO xJXNIyZpBrvXl6jBBRvS0LqwaUr0PyjMgPI0iZ2LzuBgN1EA/gd3rXUWIW45OP/JDtXD MbpA== X-Gm-Message-State: ALoCoQkbYw2/vNwVtmJbGIU0EI+TmBzb45yhjq5NOh2vXd3PYUpJiUdkxblGa/76JssIEfd76yW2 X-Received: by 10.194.19.66 with SMTP id c2mr40156073wje.141.1446063016172; Wed, 28 Oct 2015 13:10:16 -0700 (PDT) Original-Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id t126sm5483507wmd.23.2015.10.28.13.10.15 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Oct 2015 13:10:15 -0700 (PDT) Original-Received: from zen.linaro.local (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTPS id 75C993E03C9; Wed, 28 Oct 2015 20:10:14 +0000 (GMT) User-agent: mu4e 0.9.15; emacs 24.5.50.4 In-reply-to: <20151028192017.GC2538@acm.fritz.box> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::231 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:192824 Archived-At: Alan Mackenzie writes: > Hello, Emacs. > > I want to start using git branches, so as to be able to work on several > distinct things at the same time. > > My question is, how does git handle working files (which haven't been > committed) when changing from one branch to another. I've spent the > usual two hours searching the fine manuals without turning up a clear > explanation. > > One thing that worries me is that the same command "git checkout" is > used to change branches and to revert changes to a file. So it seems > plausible that each time I swap to a different branch I'm in danger of > irrevocably losing existing changes to source files. > > So, what happens to to changes in the working directory when changing > branches? > 1. git refuses to change branches because there are uncommitted > changes. By default git will complain if changing branches would revert uncommitted changes. > 2. git changes branches, discarding all uncommitted changes. You can force it to reset everything (which you don't want) > 3. git changes branches, leaving the changes from the previous branch in > the working directory. > > What I really want to happen is > 4. git maintains uncommitted changes separately in each branch. > > I suspect 4. is not the way git works. So, how do I best simulate 4.? > I would like to be able to move freely between git branches without > suffering stupid restrictions like having to worry about preserving > changes in the working directory. Is there some variant of "git stash" > which might do what I want? 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) > > TIA! -- Alex Bennée