Re: Better cooperation between checkouts and stashing

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Junio C Hamano
Date: Saturday, February 27, 2010 - 2:51 pm

Markus Elfring <Markus.Elfring@web.de> writes:


A response to a month old message is a blast from the past ;-).

The answer is "almost always" for me.  IOW, if checkout stashed away my
local changes, it would be very inconvenient.

It is important to understand that a local change does not belong to your
current branch (it does not belong to _any_ branch).  It belongs to you,
and you can take it around while switching between branches.  And that is
a big time-saving feature.

This lets you work like this:

 - You are reading a mailing list message that asks for help, and you know
   the solution---you can give the help real quick.

 - You hack in whatever branch that happen to be checked out.  The change
   is perfect, it works.

 - The branch you happen to have checked out was 'next', but the solution
   is a bugfix, and should go to 'maint'.

Now, at this point, you want to checkout 'maint' without losing your local
change.  The paths you touched with your quick fix are often not different
between the two branches, and "checkout maint" will checkout the branch
while keeping your local changes intact.  All that is left for you to do
is to run another round of test to make sure that your fix didn't depend
on anything not in 'maint' and commit the change with appropriate log
message, and then you can go back to whatever you were doing with
"checkout next".

When the change involves paths that were touched between 'maint' and
'next', of course you won't be able to switch without merging the local
change to the difference between 'next' and 'maint'.  There are a few
workflows to deal with such a case, and the easiest is "checkout -m", if
you are confident that you can resolve it.

In a case where "checkout -m" would result in a conflict too big to
resolve, the original fix you made would not be applicable to 'maint'
(iow, you should have solved it differently starting from 'maint'), and
you may end up doing "reset --hard" and start from scratch, but that is a
rare worst case.

I said it is rare, because you would notice, while doing the "quick fix"
based on 'next' codebase, that the code you are touching have changed
since 'maint' and won't be applicable to its final destination (by that
time you know you are "fixing"), and you won't waste too much time
continuing to work in a checkout of 'next'.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Better cooperation between checkouts and stashing, Markus Elfring, (Mon Feb 1, 11:50 am)
Re: Better cooperation between checkouts and stashing, Junio C Hamano, (Mon Feb 1, 1:40 pm)
Re: Better cooperation between checkouts and stashing, Markus Elfring, (Mon Feb 1, 2:57 pm)
Re: Better cooperation between checkouts and stashing, Eugene Sajine, (Mon Feb 1, 3:44 pm)
Re: Better cooperation between checkouts and stashing, Markus Elfring, (Tue Feb 2, 3:26 am)
Re: Better cooperation between checkouts and stashing, Markus Elfring, (Tue Feb 9, 12:20 pm)
Re: Better cooperation between checkouts and stashing, Junio C Hamano, (Tue Feb 9, 1:06 pm)
Re: Better cooperation between checkouts and stashing, Markus Elfring, (Tue Feb 9, 2:01 pm)
Re: Better cooperation between checkouts and stashing, Markus Elfring, (Thu Feb 18, 10:43 am)
Re: Better cooperation between checkouts and stashing, Junio C Hamano, (Thu Feb 18, 1:09 pm)
Re: Better cooperation between checkouts and stashing, Markus Elfring, (Sat Feb 27, 2:33 pm)
Re: Better cooperation between checkouts and stashing, Junio C Hamano, (Sat Feb 27, 2:51 pm)
Re: Better cooperation between checkouts and stashing, Markus Elfring, (Sun Feb 28, 6:55 am)
Re: Better cooperation between checkouts and stashing, Michael Witten, (Sun Feb 28, 3:57 pm)
Re: Better cooperation between checkouts and stashing, Markus Elfring, (Mon Mar 1, 3:50 am)
Re: Better cooperation between checkouts and stashing, Michael Witten, (Mon Mar 1, 10:02 am)
Re: Better cooperation between checkouts and stashing, Junio C Hamano, (Mon Mar 1, 10:23 am)
Re: Better cooperation between checkouts and stashing, Michael Witten, (Mon Mar 1, 11:14 am)
Re: Better cooperation between checkouts and stashing, Markus Elfring, (Mon Mar 1, 11:29 am)
Re: Better cooperation between checkouts and stashing, Junio C Hamano, (Mon Mar 1, 12:44 pm)
Re: Better cooperation between checkouts and stashing, Markus Elfring, (Mon Mar 1, 2:20 pm)
Re: Better cooperation between checkouts and stashing, Michael Witten, (Mon Mar 1, 6:41 pm)
Re: Better cooperation between checkouts and stashing, Markus Elfring, (Tue Mar 2, 2:35 am)
Re: Better cooperation between checkouts and stashing, Markus Elfring, (Tue Mar 2, 2:45 am)
Re: Better cooperation between checkouts and stashing, Junio C Hamano, (Tue Mar 2, 10:50 am)
Re: Better cooperation between checkouts and stashing, Junio C Hamano, (Tue Mar 2, 11:05 am)
Re: Better cooperation between checkouts and stashing, Markus Elfring, (Wed Mar 3, 8:55 am)
Re: Better cooperation between checkouts and stashing, Markus Elfring, (Wed Mar 3, 9:00 am)
Re: Better cooperation between checkouts and stashing, Michael Witten, (Thu Mar 4, 12:46 am)
Re: Better cooperation between checkouts and stashing, Markus Elfring, (Thu Mar 4, 12:55 pm)