From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Yuri Khan Newsgroups: gmane.emacs.devel Subject: Re: Git question: when using branches, how does git treat working files when changing branches? Date: Thu, 29 Oct 2015 08:25:26 +0600 Message-ID: References: <20151028192017.GC2538@acm.fritz.box> <87k2q6wy8p.fsf@linaro.org> <20151028223252.GD2538@acm.fritz.box> <87vb9qd2h4.fsf@wanadoo.es> <20151028235340.GE2538@acm.fritz.box> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1446085555 24507 80.91.229.3 (29 Oct 2015 02:25:55 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 29 Oct 2015 02:25:55 +0000 (UTC) Cc: =?UTF-8?Q?=C3=93scar_Fuentes?= , Emacs developers To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Oct 29 03:25:54 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 1ZrcuX-0003fE-Vr for ged-emacs-devel@m.gmane.org; Thu, 29 Oct 2015 03:25:54 +0100 Original-Received: from localhost ([::1]:41653 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrcuX-0005KN-5V for ged-emacs-devel@m.gmane.org; Wed, 28 Oct 2015 22:25:53 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34370) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrcuS-0005Hs-E6 for emacs-devel@gnu.org; Wed, 28 Oct 2015 22:25:49 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZrcuR-0002h9-Ae for emacs-devel@gnu.org; Wed, 28 Oct 2015 22:25:48 -0400 Original-Received: from mail-lf0-x235.google.com ([2a00:1450:4010:c07::235]:33434) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrcuR-0002h4-2y for emacs-devel@gnu.org; Wed, 28 Oct 2015 22:25:47 -0400 Original-Received: by lffv3 with SMTP id v3so12361759lff.0 for ; Wed, 28 Oct 2015 19:25:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type:content-transfer-encoding; bh=cd3ugLQ5/tJ9O9j5DQI+ms3shcEAK3MQWOabt3q46ak=; b=ZXoeur8FHom4+Y0ELU4tM0LQzWm6Z3mq0S3BYuoswSDWbWxJpFKtMeEpzgg/X6UjBF 0xOTTWxrdzw1Hv7BHDevRMrUz9YKHhpfP0gg/Tj+EtN1+9+WpGFaugn04pOX0d69mN1N OmjwXncl0XtTmGBDWX4t9srI+/aGIrhcQdCEgE6d6nA32fYRAmKpVQLKKm7nEhVVjo1a yLqnrirvfMItVmBytJRnXZQGYQx67jqzCzllpOPWACZ0m3DujlL3FYfrmSHmO3V5WGeS zYReB8ooCBpFdZvihc8sJOkk1VmJD7dQQAXdtK3AytbM2ARsNBND9JUKnRaICKP3adBW X69Q== X-Received: by 10.25.16.92 with SMTP id f89mr16195681lfi.1.1446085545883; Wed, 28 Oct 2015 19:25:45 -0700 (PDT) Original-Received: by 10.25.89.134 with HTTP; Wed, 28 Oct 2015 19:25:26 -0700 (PDT) In-Reply-To: <20151028235340.GE2538@acm.fritz.box> X-Google-Sender-Auth: xhIY3edAdVhbuNk1UA2xEuAl1pI X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c07::235 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:192850 Archived-At: On Thu, Oct 29, 2015 at 5:53 AM, Alan Mackenzie wrote: >> David Kastrup also suggested to commit your changes before switching >> branches, I wonder why you ignored his advice. > > It wouldn't work well for me. The word "commit" has a meaning, > something like "hand over on a permanent basis". When you make a > "commitment", you are pledging your honour that you will stand behind > what you have committed. What "commit" _doesn't_ mean is "temporarily > store because there's nowhere better". Of course there are ways of > undoing a commit if it was done by mistake. But routinely to commit to > something with the intention of repudiating it later is an abuse. It is > the sort of thing politicians do. In Git, committing is actually *the* easiest solution for the general problem of tracking uncommitted changes per-branch. In fact, =E2=80=9Cgit stash=E2=80=9D does just that: It creates two new com= mit objects (one for the working copy state, the other for the staging area state) on an unnamed branch starting at your current commit, and records the hash of the second of those commits in .git/refs/stash and in .git/logs/refs/stash. The former file is just a pointer (reference) to the last stash made. The latter is the list of all existing stashes, typically used in stack discipline (but =E2=80=9Cgit stash pop=E2=80=9D accepts an optional a= rgument specifying which stash to pop). A repository browser such as =E2=80=9Cgitk --all=E2=80=9D will show you sta= shes at the commits they were made from. Your solution of making a diff file will also work. It will also be a non-Git reimplementation of an existing Git feature (stashing), and will have all its deficiencies (tracking difficulties) and then some (e.g. an external diff file does not automatically state which commit it was made from).