All of lore.kernel.org
 help / color / mirror / Atom feed
* Stupid question on getting branch from yesterday
@ 2007-02-14 19:38 Bill Lear
  2007-02-14 19:49 ` Shawn O. Pearce
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Bill Lear @ 2007-02-14 19:38 UTC (permalink / raw)
  To: git

I have not yet figured this one out: I have not tagged anything, but
know that I checked in something lame sometime between now and two days
ago.  How do I get my working repo to be that as it was, say, yesterday?

Do I do:

% git log --since="2 days ago"

parse, the output for the commit I want, and then do

% git reset <SHA>

or would I do

% git reset --soft <SHA>

or something else?


Bill

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Stupid question on getting branch from yesterday
  2007-02-14 19:38 Stupid question on getting branch from yesterday Bill Lear
@ 2007-02-14 19:49 ` Shawn O. Pearce
  2007-02-14 19:54   ` Junio C Hamano
                     ` (2 more replies)
  2007-02-14 19:50 ` Junio C Hamano
  2007-02-14 21:13 ` Linus Torvalds
  2 siblings, 3 replies; 9+ messages in thread
From: Shawn O. Pearce @ 2007-02-14 19:49 UTC (permalink / raw)
  To: Bill Lear; +Cc: git

Bill Lear <rael@zopyra.com> wrote:
> I have not yet figured this one out: I have not tagged anything, but
> know that I checked in something lame sometime between now and two days
> ago.  How do I get my working repo to be that as it was, say, yesterday?
> 
> Do I do:
> 
> % git log --since="2 days ago"
> 
> parse, the output for the commit I want, and then do
> 
> % git reset <SHA>

No.  This would update your branch and your index to <SHA>, but
leave your working directory alone.  That's not what you want here.

Use `git checkout <SHA>` which will detach your HEAD and seek to
the commit, leaving your current commit alone.  Later you can get
back by `git checkout oldbranch`.
 
-- 
Shawn.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Stupid question on getting branch from yesterday
  2007-02-14 19:38 Stupid question on getting branch from yesterday Bill Lear
  2007-02-14 19:49 ` Shawn O. Pearce
@ 2007-02-14 19:50 ` Junio C Hamano
  2007-02-14 21:13 ` Linus Torvalds
  2 siblings, 0 replies; 9+ messages in thread
From: Junio C Hamano @ 2007-02-14 19:50 UTC (permalink / raw)
  To: Bill Lear; +Cc: git

Bill Lear <rael@zopyra.com> writes:

> I have not yet figured this one out: I have not tagged anything, but
> know that I checked in something lame sometime between now and two days
> ago.  How do I get my working repo to be that as it was, say, yesterday?
>
> Do I do:
>
> % git log --since="2 days ago"
>
> parse, the output for the commit I want, and then do
>
> % git reset <SHA>
>
> or would I do
>
> % git reset --soft <SHA>
>
> or something else?

Do you mean you have something like this:

 ---o---o---o---o---o---*---o---o HEAD
        ^               ^  
     two days           lame
     ago

and want to revert the lame one, or do you mean


 ---o---o---o---o---o---*---*---* HEAD
        ^               ^   ^   ^
     two days           lame
     ago

all are lame after certain point and want to discard all of
them?

If the latter, probably "reset --hard <first-lame-one>^" (i.e.
the parent of the first lame one) is what you want.

If the former, you may want to "git revert <lame>" or "git
rebase --onto <lame>^ <lame>".

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Stupid question on getting branch from yesterday
  2007-02-14 19:49 ` Shawn O. Pearce
@ 2007-02-14 19:54   ` Junio C Hamano
  2007-02-14 20:24   ` Bill Lear
  2007-02-14 20:28   ` Bill Lear
  2 siblings, 0 replies; 9+ messages in thread
From: Junio C Hamano @ 2007-02-14 19:54 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: Bill Lear, git

"Shawn O. Pearce" <spearce@spearce.org> writes:

> Bill Lear <rael@zopyra.com> wrote:
>> I have not yet figured this one out: I have not tagged anything, but
>> know that I checked in something lame sometime between now and two days
>> ago.  How do I get my working repo to be that as it was, say, yesterday?
>> 
>> Do I do:
>> 
>> % git log --since="2 days ago"
>> 
>> parse, the output for the commit I want, and then do
>> 
>> % git reset <SHA>
>
> No.  This would update your branch and your index to <SHA>, but
> leave your working directory alone.  That's not what you want here.
>
> Use `git checkout <SHA>` which will detach your HEAD and seek to
> the commit, leaving your current commit alone.  Later you can get
> back by `git checkout oldbranch`.

Ah, I thought Bill was talking about getting rid of lame one,
but now when I re-read his message, I think he is talking about
going there to take a look, not necessarily wanting to discard
or alter history.

Sorry, Bill, if that is the case, forget what I said about
reset/revert/rebase in the other message.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Stupid question on getting branch from yesterday
  2007-02-14 19:49 ` Shawn O. Pearce
  2007-02-14 19:54   ` Junio C Hamano
@ 2007-02-14 20:24   ` Bill Lear
  2007-02-14 20:28   ` Bill Lear
  2 siblings, 0 replies; 9+ messages in thread
From: Bill Lear @ 2007-02-14 20:24 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: Junio C Hamano, git

On Wednesday, February 14, 2007 at 14:49:19 (-0500) Shawn O. Pearce writes:
>Bill Lear <rael@zopyra.com> wrote:
>> I have not yet figured this one out: I have not tagged anything, but
>> know that I checked in something lame sometime between now and two days
>> ago.  How do I get my working repo to be that as it was, say, yesterday?
>> 
>> Do I do:
>> 
>> % git log --since="2 days ago"
>> 
>> parse, the output for the commit I want, and then do
>> 
>> % git reset <SHA>
>
>No.  This would update your branch and your index to <SHA>, but
>leave your working directory alone.  That's not what you want here.
>
>Use `git checkout <SHA>` which will detach your HEAD and seek to
>the commit, leaving your current commit alone.  Later you can get
>back by `git checkout oldbranch`.

Ah, ok, then, you can use checkout with the SHA...

Junio, I was talking about just getting back to "lame" and inspecting,
fixing, etc., not getting rid of things back to then.


Bill

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Stupid question on getting branch from yesterday
  2007-02-14 19:49 ` Shawn O. Pearce
  2007-02-14 19:54   ` Junio C Hamano
  2007-02-14 20:24   ` Bill Lear
@ 2007-02-14 20:28   ` Bill Lear
  2007-02-14 20:36     ` Jeff King
  2 siblings, 1 reply; 9+ messages in thread
From: Bill Lear @ 2007-02-14 20:28 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: git

On Wednesday, February 14, 2007 at 14:49:19 (-0500) Shawn O. Pearce writes:
>...
>Use `git checkout <SHA>` which will detach your HEAD and seek to
>the commit, leaving your current commit alone.  Later you can get
>back by `git checkout oldbranch`.

BTW, we are still using 1.4.4.1.  This will work with that?

Another BTW: this seems very similar to something that you would
tackle with git bisect (haven't used that yet), but as I understand
it, git bisect works on tags(??).

Sort of what I had in mind:

% git bisect start
% git bisect good --date="2 days ago"
% git bisect bad master
[...]



Bill

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Stupid question on getting branch from yesterday
  2007-02-14 20:28   ` Bill Lear
@ 2007-02-14 20:36     ` Jeff King
  0 siblings, 0 replies; 9+ messages in thread
From: Jeff King @ 2007-02-14 20:36 UTC (permalink / raw)
  To: Bill Lear; +Cc: git

On Wed, Feb 14, 2007 at 02:28:21PM -0600, Bill Lear wrote:

> >Use `git checkout <SHA>` which will detach your HEAD and seek to
> >the commit, leaving your current commit alone.  Later you can get
> >back by `git checkout oldbranch`.
> 
> BTW, we are still using 1.4.4.1.  This will work with that?

No. Detached HEAD is a 1.5 thing.

> Another BTW: this seems very similar to something that you would
> tackle with git bisect (haven't used that yet), but as I understand
> it, git bisect works on tags(??).

It can work on arbitrary commits. You can either pick the commit out of
git-log or gitk manually, or you can use your reflog:

  git bisect start
  git bisect good master@{2.days.ago}
  git bisect bad

-Peff

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Stupid question on getting branch from yesterday
  2007-02-14 19:38 Stupid question on getting branch from yesterday Bill Lear
  2007-02-14 19:49 ` Shawn O. Pearce
  2007-02-14 19:50 ` Junio C Hamano
@ 2007-02-14 21:13 ` Linus Torvalds
  2007-02-14 21:25   ` Junio C Hamano
  2 siblings, 1 reply; 9+ messages in thread
From: Linus Torvalds @ 2007-02-14 21:13 UTC (permalink / raw)
  To: Bill Lear; +Cc: git



On Wed, 14 Feb 2007, Bill Lear wrote:
>
> I have not yet figured this one out: I have not tagged anything, but
> know that I checked in something lame sometime between now and two days
> ago.  How do I get my working repo to be that as it was, say, yesterday?
> 
> Do I do:
> 
> % git log --since="2 days ago"
> 
> parse, the output for the commit I want, and then do
> 
> % git reset <SHA>

No, use that only if you want to throw away everything you did after 
that particular point.

If you just want to go and look at it more closely, with git-1.5 you do

	git checkout <SHA>

which will just detatch your HEAD from any current branch, and just move 
you there. But with an older git that doesn't like the detached state, 
you'd could instead do

	git checkout -b nonlame-branch <SHA>

which actually creates a new branch with the <SHA> as the beginning point, 
and switches to it. That will work with any version (including 1.5, of 
course).

You can then decide to re-do the branch without the lame commit. One 
particularly simple thing to do (if it's just one lame commit, and you 
don't want to *remove* it, but just fix it up a bit) is to literally check 
out the tip of tree juat AT the lame commit, and then you can use

	git commit --amend

to actually change it.

So depending on what your situation is, this sequence actually works:

	#
	# Create and check out a "fixes" branch that has the 
	# known-broken commit as its head commit
	#
	git checkout -b fixes <BROKEN-COMMIT>

	.. edit edit edit to fix the broken commit ..

	#
	# Then, just _replace_ the broken commit with the fixed state
	# by doing a "git commit --amend"
	#
	git commit -a --amend

	#
	# ok, now the "fixed-branch" is in good shape, but we
	# want to re-surrect our original 'master' branch WITH the 
	# fix, and based on the fixed branch, so we rebase the
	# master branch# _onto_ the fixed state in "fixes", with
	# the broken commit (that we do _not_ want to include) as
	# the base.
	#
	git rebase --onto fixes <BROKEN-COMMIT> master

Somebody else should verify that "git rebase" thing. I still find the 
syntax for that thing rather illogical for these kinds of things.  
Possibly because I never do it myself.

		Linus

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Stupid question on getting branch from yesterday
  2007-02-14 21:13 ` Linus Torvalds
@ 2007-02-14 21:25   ` Junio C Hamano
  0 siblings, 0 replies; 9+ messages in thread
From: Junio C Hamano @ 2007-02-14 21:25 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Bill Lear, git

Linus Torvalds <torvalds@linux-foundation.org> writes:

> So depending on what your situation is, this sequence actually works:
>
> 	#
> 	# Create and check out a "fixes" branch that has the 
> 	# known-broken commit as its head commit
> 	#
> 	git checkout -b fixes <BROKEN-COMMIT>
>
> 	.. edit edit edit to fix the broken commit ..
>
> 	#
> 	# Then, just _replace_ the broken commit with the fixed state
> 	# by doing a "git commit --amend"
> 	#
> 	git commit -a --amend
>
> 	#
> 	# ok, now the "fixed-branch" is in good shape, but we
> 	# want to re-surrect our original 'master' branch WITH the 
> 	# fix, and based on the fixed branch, so we rebase the
> 	# master branch# _onto_ the fixed state in "fixes", with
> 	# the broken commit (that we do _not_ want to include) as
> 	# the base.
> 	#
> 	git rebase --onto fixes <BROKEN-COMMIT> master
>
> Somebody else should verify that "git rebase" thing.

Looks fine.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2007-02-14 21:26 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-14 19:38 Stupid question on getting branch from yesterday Bill Lear
2007-02-14 19:49 ` Shawn O. Pearce
2007-02-14 19:54   ` Junio C Hamano
2007-02-14 20:24   ` Bill Lear
2007-02-14 20:28   ` Bill Lear
2007-02-14 20:36     ` Jeff King
2007-02-14 19:50 ` Junio C Hamano
2007-02-14 21:13 ` Linus Torvalds
2007-02-14 21:25   ` Junio C Hamano

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.