How to get code from last commit

I did two commits to the forked Github repo. Raised a pull request and merged that into parent Github repo. When I was testing it saw that code is not working correctly after that.

So I want the code which was there before these two commits.

I know that one way we can do is to revert the merge and get back the previous code.

But I don't want to do that I want to clone the github parent repo on my local machine and get back the previous code which was there before these two commits with out affecting parent repo. Is it possible?

If yes please help me with the commands.

Help will be appreciated.

Upvotes: 2

Views: 15781

Answers (3)

Ok thank you all for your response. Here how I solved the issue.

I cloned the repo on my local machine from parent repo. Then opened that on Git shell and used commands 'git checkout commitid' 'git checkout -b version0'

This is how I got the code before the previous two commits.

Once again I appreciate all for your time.

Upvotes: 0

aks7
aks7

Reputation: 441

Try : git log command

git log

copy the commit hash on which you want to move : Eg:

commit 1ab8684337954909d8e82fc1a7674bacff0af959
Author: abc <[email protected]>
Date:   Tue Dec 6 13:02:14 2016 +0530

git checkout 1ab8684337954909d8e82fc1a7674bacff0af959

you will move to that commit and you can check code in your working directory

Upvotes: 2

ca1c
ca1c

Reputation: 1295

All that you have to do is go on to the file that you committed on and go to the history for it, then select the earliest commit with the <> icon to view the code at that time.

Upvotes: 0

Related Questions