top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How can I get into previous version of code in git?

+1 vote
394 views

I did commit for so many times. So how can go to a particular commit code, or previous version of my code.

posted Feb 11, 2014 by Sheetal Chauhan

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

I would do a

git log

You will see a lot of lines like

commit 113efcd0eb...
Author:
Date:

Find the date you are looking for. Then you can do a

git checkout 113efcd0eb...

Which will restore the files from that commit into the working directory.

answer Feb 11, 2014 by Sonu Jindal
Similar Questions
+2 votes

As you know, I can checkout the Nth checked out branch via this syntax:

$ git checkout @{-N}

Is there a built-in mechanism to get a listing of previously checked out refs? Basically, this would be similar to 'history' command in linux where instead of actual commands, it lists like this:

HEAD@{-1}: master
HEAD@{-2}: topic1
HEAD@{-3}: 3f346e9 (detached)

Seems like reflog should be able to do this, and maybe it can, but I'm not sure. Any tips? I'd be fine making a convenient alias for this if it ends up being a series of piped commands.

+1 vote

I want to connect my android studio with git and installed git separately and when I enable version control. There is an error
"Cannot run program "git.exe" The system cannot find the file specified" searched in C drive programs files and X86 too but didn't get git.exe location.

0 votes

I need to provide a list of all branches I have merged into develop since a given date.
Can you recommend a git command that will do this?

0 votes

When I update my branch from master it pulls down several files, including some sass files. When I compile, however, gulp alerts me that I am missing .scss files.

I tested this by creating a new fresh branch and running gulp sass. This time there were no errors and I saw the missing .scss had been brought in.

Would anyone know why, on update, I am only getting some of the files from master?

0 votes

I work on some files and push/merge them to the remote server. Sometimes I get merge conflicts on those files and have to fix them. That's completely fine. I get that.

What I don't understand is that sometimes during this process I will get merge conflicts in files _I have never touched_. In fact they are in a completely different series of directories to the one I am working on and someone else project entirely. How am I meant to know how to fix these? I dont know what the other developer wanted to do and if they have done it right.

I thought git only merged/pushed the files you have changed? If someone else has changed Group A files on the remote repo, why must I change my local Group A files when I am _pushing _completely different set of Group B files?

Sure, Id understand if I were pulling files down to my local and had to resolve merge conflicts then, but this isn't happening when I push the files up.

Any help or advice is much appreciated. Sorry if I sound frustrated - I am really trying hard to get my head round this whole git thing but its just so weird.

...