* Implicit stashes
@ 2010-06-30 2:48 John Tapsell
2010-06-30 2:56 ` Joshua Jensen
2010-06-30 5:13 ` Dangers of reset --hard (Re: Implicit stashes) Jonathan Nieder
0 siblings, 2 replies; 8+ messages in thread
From: John Tapsell @ 2010-06-30 2:48 UTC (permalink / raw)
To: Git List
Hi,
I was thinking that it would be nice if everything was undoable in
git. Currently there are some easily typed by irreversible commands
that I keep seeing people doing.
For example:
$ git checkout folder
Now all changes that you just worked on are deleted, with no way of recovering.
$ git reset --hard
I know this seems very explicit to delete changes, but I myself have
done this and accidentally lost changes. For example, I write a unit
test and don't commit it in on purpose because I know that it
currently fails and I want to test it against older versions. I
carefully git checkout older versions to find if the unit test fails,
then in stupidity reset back to origin/master ..
Anyway, I think a nice solution is to have a separate stash for
implicit stashes. Then irreversible commands would simply stash
before making the changes.
It would also be nice to add a 'git undo' which just undoes whatever
the last operation was - i.e unstash or reset to an earlier HEAD@{1}
John
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Implicit stashes
2010-06-30 2:48 Implicit stashes John Tapsell
@ 2010-06-30 2:56 ` Joshua Jensen
2010-06-30 3:05 ` John Tapsell
2010-06-30 5:13 ` Dangers of reset --hard (Re: Implicit stashes) Jonathan Nieder
1 sibling, 1 reply; 8+ messages in thread
From: Joshua Jensen @ 2010-06-30 2:56 UTC (permalink / raw)
To: John Tapsell; +Cc: Git List
----- Original Message -----
From: John Tapsell
Date: 6/29/2010 8:48 PM
> I was thinking that it would be nice if everything was undoable in
> git. Currently there are some easily typed by irreversible commands
> that I keep seeing people doing.
>
> For example:
>
> $ git checkout folder
>
> Now all changes that you just worked on are deleted, with no way of recovering.
>
> $ git reset --hard
>
> I know this seems very explicit to delete changes, but I myself have
> done this and accidentally lost changes. For example, I write a unit
> test and don't commit it in on purpose because I know that it
> currently fails and I want to test it against older versions. I
> carefully git checkout older versions to find if the unit test fails,
> then in stupidity reset back to origin/master ..
> Anyway, I think a nice solution is to have a separate stash for
> implicit stashes. Then irreversible commands would simply stash
> before making the changes.
> It would also be nice to add a 'git undo' which just undoes whatever
> the last operation was - i.e unstash or reset to an earlier HEAD@{1}
See this thread: http://kerneltrap.org/mailarchive/git/2009/5/20/2915
Josh
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Implicit stashes
2010-06-30 2:56 ` Joshua Jensen
@ 2010-06-30 3:05 ` John Tapsell
2010-06-30 5:57 ` Sverre Rabbelier
0 siblings, 1 reply; 8+ messages in thread
From: John Tapsell @ 2010-06-30 3:05 UTC (permalink / raw)
To: Git List
On 30 June 2010 11:56, Joshua Jensen <jjensen@workspacewhiz.com> wrote:
> ----- Original Message -----
> From: John Tapsell
> Date: 6/29/2010 8:48 PM
>>
>> I was thinking that it would be nice if everything was undoable in
>> git. Currently there are some easily typed by irreversible commands
>> that I keep seeing people doing.
>> <snip>
> See this thread: http://kerneltrap.org/mailarchive/git/2009/5/20/2915
Doh.
It seems that everyone agreed in principle, but that the details are
tricky and it needs someone to actually do it.
I can't do it myself, but I'll give $50 to someone to get this going
and do this :) (I know that is an insultingly low amount, sorry)
John
^ permalink raw reply [flat|nested] 8+ messages in thread
* Dangers of reset --hard (Re: Implicit stashes)
2010-06-30 2:48 Implicit stashes John Tapsell
2010-06-30 2:56 ` Joshua Jensen
@ 2010-06-30 5:13 ` Jonathan Nieder
2010-06-30 8:19 ` Will Palmer
1 sibling, 1 reply; 8+ messages in thread
From: Jonathan Nieder @ 2010-06-30 5:13 UTC (permalink / raw)
To: John Tapsell; +Cc: Git List, Stephan Beyer, Christian Couder
John Tapsell wrote:
> $ git reset --hard
>
> I know this seems very explicit to delete changes, but I myself have
> done this and accidentally lost changes. For example, I write a unit
> test and don't commit it in on purpose because I know that it
> currently fails and I want to test it against older versions. I
> carefully git checkout older versions to find if the unit test fails,
> then in stupidity reset back to origin/master ..
Aside: I assume you already know about it, but still I cannot help but
take the opportunity to advertise ‘git reset --keep’. I was added
fairly recently (1.7.1 rc0) and I find myself annoyed when on machines
without it because of almost exactly this use case.
Stephan and Christian: thanks for writing it.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Implicit stashes
2010-06-30 3:05 ` John Tapsell
@ 2010-06-30 5:57 ` Sverre Rabbelier
2010-06-30 11:27 ` Alex
0 siblings, 1 reply; 8+ messages in thread
From: Sverre Rabbelier @ 2010-06-30 5:57 UTC (permalink / raw)
To: John Tapsell; +Cc: Git List
Heya,
On Wed, Jun 30, 2010 at 05:05, John Tapsell <johnflux@gmail.com> wrote:
> I can't do it myself, but I'll give $50 to someone to get this going
> and do this :) (I know that is an insultingly low amount, sorry)
Hehe, I'll match your $50 and raise you a beer ;). Isn't there some
relevant site where people can pledge for stuff like this? Either way,
I doubt for most lack of financial stimulation is what's stopping them
from implementing this, but rather lack of time which cannot really be
compensated financially.
--
Cheers,
Sverre Rabbelier
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Dangers of reset --hard (Re: Implicit stashes)
2010-06-30 5:13 ` Dangers of reset --hard (Re: Implicit stashes) Jonathan Nieder
@ 2010-06-30 8:19 ` Will Palmer
2010-06-30 16:12 ` Jonathan Nieder
0 siblings, 1 reply; 8+ messages in thread
From: Will Palmer @ 2010-06-30 8:19 UTC (permalink / raw)
To: Jonathan Nieder; +Cc: John Tapsell, Git List, Stephan Beyer, Christian Couder
On Wed, 2010-06-30 at 00:13 -0500, Jonathan Nieder wrote:
> John Tapsell wrote:
>
> > $ git reset --hard
> >
> > I know this seems very explicit to delete changes, but I myself have
> > done this and accidentally lost changes. For example, I write a unit
> > test and don't commit it in on purpose because I know that it
> > currently fails and I want to test it against older versions. I
> > carefully git checkout older versions to find if the unit test fails,
> > then in stupidity reset back to origin/master ..
>
> Aside: I assume you already know about it, but still I cannot help but
> take the opportunity to advertise ‘git reset --keep’. I was added
> fairly recently (1.7.1 rc0) and I find myself annoyed when on machines
> without it because of almost exactly this use case.
I tend to want "do a git reset --hard, but fail if anything would be
lost". The use-case here is that when I reset --hard, I want a
completely clean copy- but I don't want to accidentally lose anything.
This can probably be achieved with something like:
git diff-files --quiet &&
git diff-index --quiet HEAD &&
git diff-index --cached --quiet HEAD ||
git reset --hard "$@"
I've got a half-done patch sitting at home which adds -g, --gentle to
"git reset", which is intended to do exactly that- but my git-fu is not
very strong on the C end of things, so for the foreseeable future it
will remain an idea without a working implementation.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Implicit stashes
2010-06-30 5:57 ` Sverre Rabbelier
@ 2010-06-30 11:27 ` Alex
0 siblings, 0 replies; 8+ messages in thread
From: Alex @ 2010-06-30 11:27 UTC (permalink / raw)
To: git
Sverre Rabbelier <srabbelier <at> gmail.com> writes:
> Hehe, I'll match your $50 and raise you a beer ;). Isn't there some
> relevant site where people can pledge for stuff like this? Either way,
> I doubt for most lack of financial stimulation is what's stopping them
> from implementing this, but rather lack of time which cannot really be
> compensated financially.
There are a few:
http://fossfactory.org
http://nextsprocket.com
http://www.opensourcexperts.com/
Alex
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Dangers of reset --hard (Re: Implicit stashes)
2010-06-30 8:19 ` Will Palmer
@ 2010-06-30 16:12 ` Jonathan Nieder
0 siblings, 0 replies; 8+ messages in thread
From: Jonathan Nieder @ 2010-06-30 16:12 UTC (permalink / raw)
To: Will Palmer; +Cc: John Tapsell, Git List, Stephan Beyer, Christian Couder
Will Palmer wrote:
> I tend to want "do a git reset --hard, but fail if anything would be
> lost".
At the risk of being redundant: try git reset --keep. If it succeeds,
you can use git diff --cached HEAD and git diff to check how close it
was to being equivalent to a hard reset.
> The use-case here is that when I reset --hard, I want a
> completely clean copy- but I don't want to accidentally lose anything.
There is one case when I truly want a completely clean copy (including
no untracked files): when I am testing and a bit paranoid. For that,
I do something like the following:
; mkdir /tmp/test-dir
; git archive HEAD | (cd /tmp/test-dir && tar -xf -)
; cd /tmp/test-dir
and work from there. I would not be surprised if the needs of your
case are different, though.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2010-06-30 16:12 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-30 2:48 Implicit stashes John Tapsell
2010-06-30 2:56 ` Joshua Jensen
2010-06-30 3:05 ` John Tapsell
2010-06-30 5:57 ` Sverre Rabbelier
2010-06-30 11:27 ` Alex
2010-06-30 5:13 ` Dangers of reset --hard (Re: Implicit stashes) Jonathan Nieder
2010-06-30 8:19 ` Will Palmer
2010-06-30 16:12 ` Jonathan Nieder
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.