How to use git branch with Android Studio

Solution 1:

You should be able to do this directly from Android studio.

The easiest way is going to the bottom right corner of the Android Studio window where you should see the text "Git: branch name", in your case it should say "Git: master". Click on it and it will show a small menu consisting of the different branches available both locally and remotely, also there should be an option "+ New Branch" which will create a new branch for you and switch you to it.

You should then be able to change some code, commit it and push it to remote. Merging and checking out branches can also be done from that same menu. The same thing can also be done from the menubar option "VCS"

Solution 2:

Here's the best way I know to update the remote branches in Android Studio 1.5

1) Go to VCS > Git > Pull (make sure you've pulled your latest changes from master first)

2) Click the blue refresh button on this screen enter image description here

3) notice all your new branches show up, click on the checkbox of the one you want to switch to and click "Pull" button

4) go back to the "Git:master" menu in the bottom right of Android Studio, and you'll notice your new branch showed up in the remote section

5) click on the branch you want to checkout and select "Check out as new local branch"