1

I have a stable branch that I am doing some work on. Then to do some experimental stuff, I create another branch called experi and then started doing some work there. Then I switch back to my stable branch. However, android studio is still showing the code for the experi branch. How do I make it so that when I switch from one branch to another, android studio switches content?

I created the branch using

git checkout -b experi stable

and then to switch I do

git checkout experi

basically how do I keep the branches independent?

At least I want to be able to go back to my stable branch (before the news stuff intended for experi)

Nouvel Travay
  • 5,562
  • 11
  • 34
  • 60
  • When you create a branch, why do you want another branch name beside your command git checkout -b experi stable (In this case, why do you need stable). git checkout -b experi and git checkout experi, should take you to experi branch. Once done, do a commit in experi branch and then do git checkout stable, should bring you back to stable branch – User Feb 29 '16 at 23:41
  • `git checkout -b experi stable` means I am creating experi from stable. That is just the original step: experi has to come from somewhere. Then later in time ... hours later... I want to be able to switch back to branch stable without it being aware of anything that happened on branch experi. So `git checkout stable` should do that. But it turns out it's not doing that. The branch switches, but the experi code is till there in the IDE. – Nouvel Travay Feb 29 '16 at 23:47
  • you have to commit your changes to the experti branch. then switch back to stable ( http://rypress.com/tutorials/git/branches-1 ) – Michael D. Mar 01 '16 at 00:09
  • you mean like this: `git add .` and `git commit -a -m "comments here"`? done that. – Nouvel Travay Mar 01 '16 at 00:48
  • Have you tried doing a `gradle sync` after switch? – fergdev Mar 01 '16 at 03:21

2 Answers2

2

This is so weird. Everything I did was correct. But in order for the IDE to refresh I have to click on the bottom tab labeled "Version Control". It is next to the "Android Monitor" tab.

Nouvel Travay
  • 5,562
  • 11
  • 34
  • 60
0

Android Studio doesn't sync with your git repo. Make sure you are on the desired branch. Note: SourceTree , AS can indicate you are on a different branch . But the command line never lies.

Synchronize your gradle and clean the project.

In Android Studio : View > Tools Windows > Gradle

enter image description here

Raymond Chenon
  • 8,990
  • 10
  • 64
  • 97