James Bond
James Bond

Reputation: 67

How can I get last committed code in particular file in git bash

I am working in android and I have a file named MainActivity.class and I am init that project by using gitbash and I want to get the previous code of MainActivity.class

If I tried this then it will rollback all files to the previous code but I don't want that:

git checkout -f

Upvotes: 1

Views: 97

Answers (2)

Shyam Goyal
Shyam Goyal

Reputation: 61

you can use this following command -

git checkout commitIdOfPreviousCommit path/to/file.txt

Upvotes: 0

Vishal Beep
Vishal Beep

Reputation: 2023

If you are using Android Studio then It will be lot easier to you. Just follow These Steps

  1. In left side of your android studio editor you got a commit panel or you can press ctrl + alt + z.
  2. Then you will see a dialog then choose the file you want to rollback.

this is example image when I pressed ctrl + alt + z

enter image description here

Upvotes: 1

Related Questions