all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Alan Mackenzie <acm@muc.de>
Cc: ofv@wanadoo.es, emacs-devel@gnu.org
Subject: Re: Git question: when using branches, how does git treat working	files when changing branches?
Date: Thu, 29 Oct 2015 18:16:46 +0200	[thread overview]
Message-ID: <83611p3b0x.fsf@gnu.org> (raw)
In-Reply-To: <20151028235340.GE2538@acm.fritz.box>

> Date: Wed, 28 Oct 2015 23:53:40 +0000
> From: Alan Mackenzie <acm@muc.de>
> Cc: emacs-devel@gnu.org
> 
> > 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.
> 
> Committed software and work in progress are two different categories of
> code.  To confuse them must lead to trouble.

I suggest that you rethink this concept.  What you describe makes
sense when using centralized VCS, where "commit" goes upstream and is
immediately made public; doing this with unfinished work is unwise, of
course.

But you are using a dVCS, where commits are local until pushed.
Moreover, I understand that your entire branch is local, which means
none of what you do on that branch is visible to anyone but you.  This
makes the grave meaning you seem to assign to a commit null and void.

In a dVCS, local commits are best used for your own personal tracking
of your work, a kind of log that is automagically linked to the code
changes you make as you go.  Which means, in particular, that you and
you alone determine when it's okay to commit, and the commit log
messages don't have to make sense to anyone but you.

Given all that, committing frequently on such a branch makes a lot of
sense, because it lets you track your work with much more fine-grained
resolution.  An immediate benefit is that you no longer need to depend
on your memory to remember when and why you made some change -- you
can see it with VCS commands, and you can put into the log messages
the rationale that will explain the "why" part.  Another significant
benefit is that bisecting bugs you find later gives much more precise
results, and, with good log messages, it's easy to quickly understand
why you made the offending change, and how to test the alternative
solution to be sure it doesn't break whatever reason that led you to
that change.

It goes without saying that even with this workflow, some commits are
"more equal" than others.  Examples include commits you make after you
finish testing some of your code, commits you make after a meaningful
part of the feature is done, etc.  But it's easy to indicate the
significance of these commits in the log messages, so they are later
easily identified in the commit log.  IOW, you have all the means to
support both "meaningful" commits and the less-meaningful ones.  The
latter kinds could have a log message such as

  Finished coding FOO, but didn't test it yet.

or even

  Wrote function 'foobar', but didn't try to compile it yet.

The messages make it clear these commits are unfinished WIP, but so
what? it's your own personal log that it's nobody's business to read.

> If I were were to commit unfinished changes just for lack of somewhere
> proper to store them, inevitably some of these changes would find
> themselves becoming permanent, embarassingly so.

This issue, if it bothers you, have an easy solution: when you are
done with your feature, instead of merging it onto master, _rebase_ it
on the master branch using Git's "rebase -i" command.  That allows you
to squash all your local commits into a single commit on master.  (The
exact procedure can be found via Google and is described under
"Interactive Mode" on the "git rebase" man page; search for "squash"
in that description.)

FWIW, I'm generally not bothered to have my local commits be visible
after I merge the feature branch, so I just use "git merge".  But
that's me; I know that some people don't like to show their local
history, and prefer "rebase".

Bottom line, a dVCS gives you some useful new functionalities, and
some of that justifies rethinking your old habits, in order to make
you work more convenient.  I think this is one of them.

P.S. I see that David wrote something very similar in spirit.



  parent reply	other threads:[~2015-10-29 16:16 UTC|newest]

Thread overview: 90+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-28 19:20 Git question: when using branches, how does git treat working files when changing branches? Alan Mackenzie
2015-10-28 19:44 ` David Kastrup
2015-10-28 20:00 ` Steinar Bang
2015-10-28 20:04 ` Ricardo Wurmus
2015-10-28 20:10 ` Alex Bennée
2015-10-28 22:32   ` Alan Mackenzie
2015-10-28 22:56     ` Xue Fuqiao
2015-10-28 22:59     ` Óscar Fuentes
2015-10-28 23:53       ` Alan Mackenzie
2015-10-29  0:17         ` Dmitry Gutov
2015-10-29  0:28         ` Michael Heerdegen
2015-10-29  0:49           ` Michael Heerdegen
2015-10-29  2:25         ` Yuri Khan
2015-10-29  8:21         ` David Kastrup
2015-10-29 12:35           ` Alan Mackenzie
2015-10-29 13:21             ` David Kastrup
2015-10-29 17:02               ` On the popularity of git [Was: Git question: when using branches, how does git treat working files when changing branches?] Alan Mackenzie
2015-10-29 17:22                 ` David Kastrup
2015-10-29 18:08                 ` John Wiegley
2015-10-30  7:48                 ` Paul Eggert
2015-10-30  9:27                   ` Alan Mackenzie
2015-10-30  9:48                     ` David Kastrup
2015-10-30 10:34                     ` Eli Zaretskii
2015-10-30 21:44                     ` Paul Eggert
2015-10-30  9:09                 ` joakim
2015-10-30 10:49                   ` Yuri Khan
2015-10-31  3:16                     ` Stephen J. Turnbull
2015-10-31  8:24                       ` Eli Zaretskii
2015-10-31  8:32                         ` Andreas Schwab
2015-10-31 11:35                         ` Oleh Krehel
2015-10-31 12:19                         ` David Kastrup
2015-11-02 22:01                           ` Nikolaus Rath
2015-11-03  8:42                             ` David Kastrup
2015-11-03 17:38                               ` Nikolaus Rath
2015-10-31 16:02                         ` On the popularity of git Stephen J. Turnbull
2015-11-01  8:08                           ` Uwe Brauer
2015-10-31 16:50                       ` Alan Mackenzie
2015-10-31 16:58                         ` Dmitry Gutov
2015-11-02 22:05                           ` Nikolaus Rath
2015-11-03  8:39                             ` David Kastrup
2015-10-31 19:24                         ` Stephen J. Turnbull
2015-10-31 20:13                           ` David Kastrup
2015-10-31 21:08                         ` Steinar Bang
2015-10-31 21:15                           ` David Kastrup
2015-10-31 21:48                           ` Alan Mackenzie
2015-11-01  8:17                             ` Steinar Bang
2015-11-01  8:54                               ` David Kastrup
2015-11-01 10:17                                 ` Steinar Bang
2015-11-01 11:15                                   ` Juanma Barranquero
2015-11-02 20:11                                     ` John Wiegley
2015-11-03  7:00                                       ` Oleh Krehel
2015-11-03 10:07                                         ` Dmitry Gutov
2015-11-03 11:58                                           ` Juanma Barranquero
2015-11-03 13:08                                             ` John Wiegley
2015-11-03 13:30                                               ` Juanma Barranquero
2015-11-03 13:38                                                 ` Dmitry Gutov
2015-11-03 13:43                                                   ` Juanma Barranquero
2015-11-03 13:49                                                     ` Dmitry Gutov
2015-11-03 13:58                                                       ` Juanma Barranquero
2015-11-03 14:14                                                         ` Alan Mackenzie
2015-11-03 14:25                                                           ` Juanma Barranquero
2015-11-03 13:43                                                 ` Oleh Krehel
2015-11-03 14:35                                                   ` Óscar Fuentes
2015-11-03 14:52                                                     ` Juanma Barranquero
2015-11-03 15:58                                                     ` Eli Zaretskii
2015-11-03 16:04                                                       ` Dmitry Gutov
2015-11-03 18:14                                                         ` Óscar Fuentes
2015-11-03 19:40                                                     ` Jay Belanger
2015-11-03 20:15                                                       ` John Wiegley
2015-11-03 20:24                                                         ` Drew Adams
2015-11-03 20:35                                                           ` Changing the tone of emacs-devel (Was: On the popularity of git) John Wiegley
2015-11-03 22:05                                                             ` Artur Malabarba
2015-11-04  7:54                                                               ` Nicolas Petton
2015-11-03 21:47                                                         ` Changing the subject (was: " David Kastrup
2015-11-03 23:37                                                           ` Marcin Borkowski
2015-11-04  0:27                                                             ` John Yates
2015-11-04  1:40                                                           ` Changing the subject Yann Hodique
2015-11-04 15:37                                                             ` John Wiegley
2015-11-03 22:11                                                         ` emacs-devel etiquette (was: Re: On the popularity of git) Stephen Leake
2015-11-04 11:12                                                         ` Future emacs mailing lists. [Was: On the popularity of git] Alan Mackenzie
2015-11-04  7:52                                                   ` On the popularity of git Stephen J. Turnbull
2015-11-03 20:53                                                 ` Richard Stallman
2015-11-03 13:49                                           ` Andreas Schwab
2015-10-30 12:50                 ` On the popularity of git [Was: Git question: when using branches, how does git treat working files when changing branches?] Juanma Barranquero
2015-10-30 14:15                   ` David Kastrup
2015-10-30 16:54                     ` Juanma Barranquero
2015-10-30 17:31                       ` David Kastrup
2015-10-29 16:31             ` Git question: when using branches, how does git treat working files when changing branches? Eli Zaretskii
2015-10-29 16:16         ` Eli Zaretskii [this message]
2015-10-29 17:45         ` Davis Herring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83611p3b0x.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=acm@muc.de \
    --cc=emacs-devel@gnu.org \
    --cc=ofv@wanadoo.es \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.