{"thread":{"id":"6825","subject":"Stupid question on getting branch from yesterday","startedAt":"2007-02-14T19:38:02Z","lastAt":"2007-02-14T21:25:58Z","messageCount":9,"participants":["Bill Lear","Shawn O. Pearce","Junio C Hamano","Jeff King","Linus Torvalds"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"34611","messageId":"17875.25882.784307.731860@lisa.zopyra.com","threadId":"6825","inReplyTo":null,"subject":"Stupid question on getting branch from yesterday","fromName":"Bill Lear","fromEmail":"rael@zopyra.com","sentAt":"2007-02-14T19:38:02Z","receivedAt":"2007-02-14T19:38:02Z","isPatch":false,"sender":{"key":"rael@zopyra.com","avatar":"https://gravatar.com/avatar/c4f2d2790ca3828d3b4e7dfebabf61d2fe94fd82fa49cdac2a5295dd2d46a874?d=mp&s=160"},"body":"I have not yet figured this one out: I have not tagged anything, but\nknow that I checked in something lame sometime between now and two days\nago.  How do I get my working repo to be that as it was, say, yesterday?\n\nDo I do:\n\n% git log --since=\"2 days ago\"\n\nparse, the output for the commit I want, and then do\n\n% git reset <SHA>\n\nor would I do\n\n% git reset --soft <SHA>\n\nor something else?\n\n\nBill\n"},{"id":"34615","messageId":"20070214194919.GE28290@spearce.org","threadId":"6825","inReplyTo":"17875.25882.784307.731860@lisa.zopyra.com","subject":"Re: Stupid question on getting branch from yesterday","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-02-14T19:49:19Z","receivedAt":"2007-02-14T19:49:19Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Bill Lear <rael@zopyra.com> wrote:\n> I have not yet figured this one out: I have not tagged anything, but\n> know that I checked in something lame sometime between now and two days\n> ago.  How do I get my working repo to be that as it was, say, yesterday?\n> \n> Do I do:\n> \n> % git log --since=\"2 days ago\"\n> \n> parse, the output for the commit I want, and then do\n> \n> % git reset <SHA>\n\nNo.  This would update your branch and your index to <SHA>, but\nleave your working directory alone.  That's not what you want here.\n\nUse `git checkout <SHA>` which will detach your HEAD and seek to\nthe commit, leaving your current commit alone.  Later you can get\nback by `git checkout oldbranch`.\n \n-- \nShawn.\n"},{"id":"34616","messageId":"7vbqjwo6xb.fsf@assigned-by-dhcp.cox.net","threadId":"6825","inReplyTo":"17875.25882.784307.731860@lisa.zopyra.com","subject":"Re: Stupid question on getting branch from yesterday","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-02-14T19:50:08Z","receivedAt":"2007-02-14T19:50:08Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Bill Lear <rael@zopyra.com> writes:\n\n> I have not yet figured this one out: I have not tagged anything, but\n> know that I checked in something lame sometime between now and two days\n> ago.  How do I get my working repo to be that as it was, say, yesterday?\n>\n> Do I do:\n>\n> % git log --since=\"2 days ago\"\n>\n> parse, the output for the commit I want, and then do\n>\n> % git reset <SHA>\n>\n> or would I do\n>\n> % git reset --soft <SHA>\n>\n> or something else?\n\nDo you mean you have something like this:\n\n ---o---o---o---o---o---*---o---o HEAD\n        ^               ^  \n     two days           lame\n     ago\n\nand want to revert the lame one, or do you mean\n\n\n ---o---o---o---o---o---*---*---* HEAD\n        ^               ^   ^   ^\n     two days           lame\n     ago\n\nall are lame after certain point and want to discard all of\nthem?\n\nIf the latter, probably \"reset --hard <first-lame-one>^\" (i.e.\nthe parent of the first lame one) is what you want.\n\nIf the former, you may want to \"git revert <lame>\" or \"git\nrebase --onto <lame>^ <lame>\".\n"},{"id":"34617","messageId":"7v7iuko6qp.fsf@assigned-by-dhcp.cox.net","threadId":"6825","inReplyTo":"20070214194919.GE28290@spearce.org","subject":"Re: Stupid question on getting branch from yesterday","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-02-14T19:54:06Z","receivedAt":"2007-02-14T19:54:06Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Shawn O. Pearce\" <spearce@spearce.org> writes:\n\n> Bill Lear <rael@zopyra.com> wrote:\n>> I have not yet figured this one out: I have not tagged anything, but\n>> know that I checked in something lame sometime between now and two days\n>> ago.  How do I get my working repo to be that as it was, say, yesterday?\n>> \n>> Do I do:\n>> \n>> % git log --since=\"2 days ago\"\n>> \n>> parse, the output for the commit I want, and then do\n>> \n>> % git reset <SHA>\n>\n> No.  This would update your branch and your index to <SHA>, but\n> leave your working directory alone.  That's not what you want here.\n>\n> Use `git checkout <SHA>` which will detach your HEAD and seek to\n> the commit, leaving your current commit alone.  Later you can get\n> back by `git checkout oldbranch`.\n\nAh, I thought Bill was talking about getting rid of lame one,\nbut now when I re-read his message, I think he is talking about\ngoing there to take a look, not necessarily wanting to discard\nor alter history.\n\nSorry, Bill, if that is the case, forget what I said about\nreset/revert/rebase in the other message.\n"},{"id":"34620","messageId":"17875.28649.796301.17874@lisa.zopyra.com","threadId":"6825","inReplyTo":"20070214194919.GE28290@spearce.org","subject":"Re: Stupid question on getting branch from yesterday","fromName":"Bill Lear","fromEmail":"rael@zopyra.com","sentAt":"2007-02-14T20:24:09Z","receivedAt":"2007-02-14T20:24:09Z","isPatch":false,"sender":{"key":"rael@zopyra.com","avatar":"https://gravatar.com/avatar/c4f2d2790ca3828d3b4e7dfebabf61d2fe94fd82fa49cdac2a5295dd2d46a874?d=mp&s=160"},"body":"On Wednesday, February 14, 2007 at 14:49:19 (-0500) Shawn O. Pearce writes:\n>Bill Lear <rael@zopyra.com> wrote:\n>> I have not yet figured this one out: I have not tagged anything, but\n>> know that I checked in something lame sometime between now and two days\n>> ago.  How do I get my working repo to be that as it was, say, yesterday?\n>> \n>> Do I do:\n>> \n>> % git log --since=\"2 days ago\"\n>> \n>> parse, the output for the commit I want, and then do\n>> \n>> % git reset <SHA>\n>\n>No.  This would update your branch and your index to <SHA>, but\n>leave your working directory alone.  That's not what you want here.\n>\n>Use `git checkout <SHA>` which will detach your HEAD and seek to\n>the commit, leaving your current commit alone.  Later you can get\n>back by `git checkout oldbranch`.\n\nAh, ok, then, you can use checkout with the SHA...\n\nJunio, I was talking about just getting back to \"lame\" and inspecting,\nfixing, etc., not getting rid of things back to then.\n\n\nBill\n"},{"id":"34621","messageId":"17875.28901.705687.843342@lisa.zopyra.com","threadId":"6825","inReplyTo":"20070214194919.GE28290@spearce.org","subject":"Re: Stupid question on getting branch from yesterday","fromName":"Bill Lear","fromEmail":"rael@zopyra.com","sentAt":"2007-02-14T20:28:21Z","receivedAt":"2007-02-14T20:28:21Z","isPatch":false,"sender":{"key":"rael@zopyra.com","avatar":"https://gravatar.com/avatar/c4f2d2790ca3828d3b4e7dfebabf61d2fe94fd82fa49cdac2a5295dd2d46a874?d=mp&s=160"},"body":"On Wednesday, February 14, 2007 at 14:49:19 (-0500) Shawn O. Pearce writes:\n>...\n>Use `git checkout <SHA>` which will detach your HEAD and seek to\n>the commit, leaving your current commit alone.  Later you can get\n>back by `git checkout oldbranch`.\n\nBTW, we are still using 1.4.4.1.  This will work with that?\n\nAnother BTW: this seems very similar to something that you would\ntackle with git bisect (haven't used that yet), but as I understand\nit, git bisect works on tags(??).\n\nSort of what I had in mind:\n\n% git bisect start\n% git bisect good --date=\"2 days ago\"\n% git bisect bad master\n[...]\n\n\n\nBill\n"},{"id":"34622","messageId":"20070214203626.GB14729@coredump.intra.peff.net","threadId":"6825","inReplyTo":"17875.28901.705687.843342@lisa.zopyra.com","subject":"Re: Stupid question on getting branch from yesterday","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2007-02-14T20:36:26Z","receivedAt":"2007-02-14T20:36:26Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Feb 14, 2007 at 02:28:21PM -0600, Bill Lear wrote:\n\n> >Use `git checkout <SHA>` which will detach your HEAD and seek to\n> >the commit, leaving your current commit alone.  Later you can get\n> >back by `git checkout oldbranch`.\n> \n> BTW, we are still using 1.4.4.1.  This will work with that?\n\nNo. Detached HEAD is a 1.5 thing.\n\n> Another BTW: this seems very similar to something that you would\n> tackle with git bisect (haven't used that yet), but as I understand\n> it, git bisect works on tags(??).\n\nIt can work on arbitrary commits. You can either pick the commit out of\ngit-log or gitk manually, or you can use your reflog:\n\n  git bisect start\n  git bisect good master@{2.days.ago}\n  git bisect bad\n\n-Peff\n"},{"id":"34628","messageId":"Pine.LNX.4.64.0702141250300.20368@woody.linux-foundation.org","threadId":"6825","inReplyTo":"17875.25882.784307.731860@lisa.zopyra.com","subject":"Re: Stupid question on getting branch from yesterday","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2007-02-14T21:13:09Z","receivedAt":"2007-02-14T21:13:09Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Wed, 14 Feb 2007, Bill Lear wrote:\n>\n> I have not yet figured this one out: I have not tagged anything, but\n> know that I checked in something lame sometime between now and two days\n> ago.  How do I get my working repo to be that as it was, say, yesterday?\n> \n> Do I do:\n> \n> % git log --since=\"2 days ago\"\n> \n> parse, the output for the commit I want, and then do\n> \n> % git reset <SHA>\n\nNo, use that only if you want to throw away everything you did after \nthat particular point.\n\nIf you just want to go and look at it more closely, with git-1.5 you do\n\n\tgit checkout <SHA>\n\nwhich will just detatch your HEAD from any current branch, and just move \nyou there. But with an older git that doesn't like the detached state, \nyou'd could instead do\n\n\tgit checkout -b nonlame-branch <SHA>\n\nwhich actually creates a new branch with the <SHA> as the beginning point, \nand switches to it. That will work with any version (including 1.5, of \ncourse).\n\nYou can then decide to re-do the branch without the lame commit. One \nparticularly simple thing to do (if it's just one lame commit, and you \ndon't want to *remove* it, but just fix it up a bit) is to literally check \nout the tip of tree juat AT the lame commit, and then you can use\n\n\tgit commit --amend\n\nto actually change it.\n\nSo depending on what your situation is, this sequence actually works:\n\n\t#\n\t# Create and check out a \"fixes\" branch that has the \n\t# known-broken commit as its head commit\n\t#\n\tgit checkout -b fixes <BROKEN-COMMIT>\n\n\t.. edit edit edit to fix the broken commit ..\n\n\t#\n\t# Then, just _replace_ the broken commit with the fixed state\n\t# by doing a \"git commit --amend\"\n\t#\n\tgit commit -a --amend\n\n\t#\n\t# ok, now the \"fixed-branch\" is in good shape, but we\n\t# want to re-surrect our original 'master' branch WITH the \n\t# fix, and based on the fixed branch, so we rebase the\n\t# master branch# _onto_ the fixed state in \"fixes\", with\n\t# the broken commit (that we do _not_ want to include) as\n\t# the base.\n\t#\n\tgit rebase --onto fixes <BROKEN-COMMIT> master\n\nSomebody else should verify that \"git rebase\" thing. I still find the \nsyntax for that thing rather illogical for these kinds of things.  \nPossibly because I never do it myself.\n\n\t\tLinus\n"},{"id":"34635","messageId":"7vire4mnx5.fsf@assigned-by-dhcp.cox.net","threadId":"6825","inReplyTo":"Pine.LNX.4.64.0702141250300.20368@woody.linux-foundation.org","subject":"Re: Stupid question on getting branch from yesterday","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-02-14T21:25:58Z","receivedAt":"2007-02-14T21:25:58Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Linus Torvalds <torvalds@linux-foundation.org> writes:\n\n> So depending on what your situation is, this sequence actually works:\n>\n> \t#\n> \t# Create and check out a \"fixes\" branch that has the \n> \t# known-broken commit as its head commit\n> \t#\n> \tgit checkout -b fixes <BROKEN-COMMIT>\n>\n> \t.. edit edit edit to fix the broken commit ..\n>\n> \t#\n> \t# Then, just _replace_ the broken commit with the fixed state\n> \t# by doing a \"git commit --amend\"\n> \t#\n> \tgit commit -a --amend\n>\n> \t#\n> \t# ok, now the \"fixed-branch\" is in good shape, but we\n> \t# want to re-surrect our original 'master' branch WITH the \n> \t# fix, and based on the fixed branch, so we rebase the\n> \t# master branch# _onto_ the fixed state in \"fixes\", with\n> \t# the broken commit (that we do _not_ want to include) as\n> \t# the base.\n> \t#\n> \tgit rebase --onto fixes <BROKEN-COMMIT> master\n>\n> Somebody else should verify that \"git rebase\" thing.\n\nLooks fine.\n"}]}