threads / discuss / 13693

Reverting to old commit

Subject: Reverting to old commit

## tl;dr

8 messages between May 27, 2008 and May 27, 2008.

replies: 7people: 7as markdown or json

Marcus· May 27, 2008, 17:50 UTC · lore
Newbie question: What's the simplest way to find an old commit and revert?

Say you have a version from yesterday which worked and today's experiments failed, so you want to go back to that working version. Unfortunately, it's not tagged. Instead you need to actually view the code to identify the version you want. I thought maybe gitk might help, but I can't find my way with gitk. I hoped you could browse revisions easier in a GUI and tell gitk or git-gui to revert?

Thanks,
Marcus
Jakub Narebski· May 27, 2008, 18:09 UTC · re: Marcus · lore

Re: Reverting to old commit

Marcus <prima@wordit.com> writes:
Show 8 quoted lines
> Newbie question: What's the simplest way to find an old commit and revert?
> 
> Say you have a version from yesterday which worked and today's
> experiments failed, so you want to go back to that working version.
> Unfortunately, it's not tagged. Instead you need to actually view the
> code to identify the version you want. I thought maybe gitk might
> help, but I can't find my way with gitk. I hoped you could browse
> revisions easier in a GUI and tell gitk or git-gui to revert?
Errr... isn't it what git-bisect is for?
If it is not, viewing git-log, or git-reflog output should help...
-- 
Jakub Narebski
Poland
ShadeHawk on #git
Brandon Casey· May 27, 2008, 20:43 UTC · re: Jakub Narebski · lore

Re: Reverting to old commit

Jakub Narebski wrote:
Show 14 quoted lines
> Marcus <prima@wordit.com> writes:
> 
>> Newbie question: What's the simplest way to find an old commit and revert?
>>
>> Say you have a version from yesterday which worked and today's
>> experiments failed, so you want to go back to that working version.
>> Unfortunately, it's not tagged. Instead you need to actually view the
>> code to identify the version you want. I thought maybe gitk might
>> help, but I can't find my way with gitk. I hoped you could browse
>> revisions easier in a GUI and tell gitk or git-gui to revert?
> 
> Errr... isn't it what git-bisect is for?
> 
> If it is not, viewing git-log, or git-reflog output should help...

Shouldn't we be encouraging the use of 'git log -g' rather than 'git reflog'? git-reflog seems more like plumbing than porcelain to me.

-brandon
Sverre Rabbelier· May 27, 2008, 23:00 UTC · re: Brandon Casey · lore

Re: Reverting to old commit

On Tue, May 27, 2008 at 10:43 PM, Brandon Casey <casey@nrlssc.navy.mil> wrote:
> Shouldn't we be encouraging the use of 'git log -g' rather than 'git reflog'?
> git-reflog seems more like plumbing than porcelain to me.

I had no idea, but then again, the man pages don't mention whether something is plumbing or porcelain anywhere... But I guess 'git log -g' is easier to use (since it supplies the user with most of git log's features) than git reflog. I was introduced to reflog by someone advising me to use it, so I was merely "passing on" that advice, unknowing of 'git log -g' :).

-- 
Cheers,

Sverre Rabbelier
Sverre Rabbelier· May 27, 2008, 19:32 UTC · re: Marcus · lore

Re: Reverting to old commit

On Tue, May 27, 2008 at 7:50 PM, Marcus <prima@wordit.com> wrote:
Show 8 quoted lines
> Newbie question: What's the simplest way to find an old commit and revert?
>
> Say you have a version from yesterday which worked and today's
> experiments failed, so you want to go back to that working version.
> Unfortunately, it's not tagged. Instead you need to actually view the
> code to identify the version you want. I thought maybe gitk might
> help, but I can't find my way with gitk. I hoped you could browse
> revisions easier in a GUI and tell gitk or git-gui to revert?

Have a look at the reflog (git reflog) perhaps combined with "git log -p" which will show the changes each commit introduced as well.

-- 
Cheers,

Sverre Rabbelier
Dirk Süsserott· May 27, 2008, 20:02 UTC · re: Marcus · lore

Re: Reverting to old commit

Marcus schrieb:
Show 18 quoted lines
> Newbie question: What's the simplest way to find an old commit and revert?
>
> Say you have a version from yesterday which worked and today's
> experiments failed, so you want to go back to that working version.
> Unfortunately, it's not tagged. Instead you need to actually view the
> code to identify the version you want. I thought maybe gitk might
> help, but I can't find my way with gitk. I hoped you could browse
> revisions easier in a GUI and tell gitk or git-gui to revert?
>
> Thanks,
>
> Marcus
> --
> 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
>
>   

Probably I misunderstood, but: do you *know* which version worked well? I.e. when you start gitk, can you point to the working commit and are just wondering how to revert to that one?

Then gitk's "reset ... branch to here" could help you. Right-click the desired commit and reset the branch.

There's no need to have a tag for this. You can even create a tag afterwards for any commit you like. It's just an alias for the commit id (sha1).

If you cannot identify the working commit, then please forget my answer and follow the "git bisect" proposals.

Paolo Bonzini· May 27, 2008, 20:17 UTC · re: Dirk Süsserott · lore

Re: Reverting to old commit

> Then gitk's "reset ... branch to here" could help you. Right-click
> the desired commit and reset the branch.
DON'T do this though if you have published the branch somewhere.

Do "git-revert -n" on all the commits after the buggy one in that case, starting from the last, then "git commit".

Paolo
Robin Rosenberg· May 27, 2008, 20:41 UTC · re: Marcus · lore

Re: Reverting to old commit

tisdagen den 27 maj 2008 19.50.31 skrev Marcus:
Show 8 quoted lines
> Newbie question: What's the simplest way to find an old commit and revert?
> 
> Say you have a version from yesterday which worked and today's
> experiments failed, so you want to go back to that working version.
> Unfortunately, it's not tagged. Instead you need to actually view the
> code to identify the version you want. I thought maybe gitk might
> help, but I can't find my way with gitk. I hoped you could browse
> revisions easier in a GUI and tell gitk or git-gui to revert?

If you know a line of code that you know or suspect is wrong, you can find the commit that introduced the version using git blame.

-- robin

← back to recent threads