There are a bunch of decade-old answers for using git command line to accomplish various goals, but this question is how to use the standard git plugin for Android Studio 3.3.1, GUI only to “fix” a common “problem”. Maybe it’s “impossible” without git command line. If so, then that’s the answer: “impossible”, but you would have to wonder about the authors of the VSC plug-in.
You would like to test some code that’s hosted on github.com and you only want to use the GUI of Android Studio. You’re asked to test but don’t know how to switch branches and keep an exact match with the code you’re supposed to be testing. You have read-only access to the remotes.
Checkout / Clone
Within Android Studio, you select
VCS > Checkout from Version Control > Git, then you paste the url you found while using your web browser. So it might be something like
https://github.com/someguy42/someproggy42. You hit the test button and it says Connection successful. Then you hit the Clone button.
You check the remotes:
VCS > Git > Remotes... If the one you want isn’t there, you do
(plus sign) > (url of repository found in github.com). You specify the name of this remote as
You then do a fetch
VCS > Git > Fetch. At the bottom right of the Android studio, you click and you see
someguy42feature2. You note on the web that both features branched off from master.
All is well. So far.
Testing Two Branches
You are asked to test both features.
So from the list you see by left clicking on the bottom right of the IDE, you right click on
someguy42feature1 > Checkout As... > feature1.
You complete your work on feature 1. Maybe you add a logging statement or something, but nothing you care to save.
Now it’s time for feature 2, so you repeat the process as before: from list on the bottom right of the IDE, you right click on
someguy42feature2 > Checkout As... > feature2.
You notice something odd. You now have a mixture of feature1 and feature2 in your IDE!
You prove this to yourself by going to the Android
app folder, right click and select
Git > Compare with Branch... and you compare with the remote
someguy42master. You expect to see only files changed in feature2, but both feature1 and feature2 files are in the list.
What steps, executed exclusively through the Android Studio GUI and the VCS plug-in, would make it so your working copy was a guaranteed pristine copy of only files from feature2?