user1785730
user1785730

Reputation: 3535

How do I checkout an old git commit in Android Studio?

I would like to look at an old commit of my app in Android Studio in order to compile and run it. I don’t want to reset back to the previous commit or change my commit history or anything like that. When I’m done, I want to go back to the latest version.

On the command line, this would be a simple

git checkout <hash>

So how can I do this in Android Studio?

I haven’t tried to do it on the command line, because I’m afraid Android Studio might get heartburn when I modify its files externally. Reassurance that I can work with git outside of Android Studio without problem would be fine too.

Upvotes: 12

Views: 14841

Answers (2)

Yatin Batra
Yatin Batra

Reputation: 46

A git repository contains the all history at all time. So when you are cloning a repository, you are cloning it with its full history, and then, you can make a branch from whatever commit you want:

$ git checkout -b aNewBranch SHA1

with SHA1 representing the commit id from which you want to proceed.

Upvotes: 1

Kamil
Kamil

Reputation: 2860

If you want to checkout commit using Android Studio (or other IntelliJ IDEA based IDE) just go toVersion Control view (alt+9) and click the Log tab. Type your commit hash in Filter input, right-click on the commit entry and click the Checkout Revision option.

What's more, if you want to work with a command line, simply use git from command line. I'm working with Git using only command line and nothing wrong happend yet. The only thing that you have to remember is to wait for reindexing end.

Upvotes: 48

Related Questions