On Tue, 3 Sep 2013 08:05:23 -0700 (PDT)
maya melnick <maya778...@yahoo.com> wrote:

> but I imagine in other situations, to have to commit every time
> before switching branches is weird... what if you haven't finished
> work on a branch and need to switch branches to take care of another
> problem, but don't want to commit what you just did because, well,
> you're not ready to commit?  ;-)

You do not *have to* commit -- if you dislike the idea of
work-in-progress commits, then just use stash -- it was invented
precisely for dealing with such scenarious when you want to
disrupt your hacking session to switch to another branch temporarily
to do, say, a quick fix.

But it helps to actually ponder the possibility of throw-away commits
even if you do not intend to use them.  This is because in Git
philosophy your *local* (unpushed) history is not "sacred" (this is
in stark contrast with certain other DVCS systems, for instance, Fossil
[1] in which each commit is cast in stone), and you're free to
manipulate it however you're pleased to do so until it's pushed
somewhere else.  This allows you to spit a series of miniscule dirty
commits and then lump them together to form a larger beautiful
commit or several of them and "bless" the result as something you
intend to share or publish.

If you lament the fact the work tree is not tied to a branch then
there's nothing which could be do to it -- this is the design choice,
and Git developers are highly unlikely to ever change that.

It also helps pondering that there are technical difficulties
implementing such affinity: what to do with untracked files?
Obviously, when you hack a feature, you're likely to create new files
-- should Git auto save them when you switch branches?  Yes?  But what
if while hacking that feature you performed a test run of your program
and it spewed a few hundred gigabytes of tracing data to your work tree?
Saving just everything hence has unexpected (and possibly crazy) hidden
costs, and not saving everything has the great WTF potential.  So in
fact what Git does is a) simple and predictable, and b) has low WTF
potential once you know the rules (and you do now).

1. http://www.fossil-scm.org

You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to