I recently created a new project in Android Studio and started working on it. After writing some activity classes I added git integration to my project. But to my surprise when I pushed the project, It pushed one directory higher than my project’s root dir. It contained all the projects I had worked on. I had to delete the repository and create a new one.
I even tried to change the directory from Android Studio > Preferences > Version Control. But it returned an error saying “invalid vcs root mapping“. Even rebuilt the project, did invalidate cache and restart but no help. So what’s wrong here?
The problem is that Android Studio had put the .git to the wrong directory. I don’t know why and how, but if something similar happens to you, follow the instructions below.
Move .git from wrong directory to Project directory
- Open Terminal in Android Studio (with your Awesome Project open).
- Go to the “wrong” directory where .git is located (See that in Version Control settings).
- Run this command.
mv .git /MyAwesomeProject
- Go back to Version Control settings (Android Studio > Preferences > Version Control) and add your project directory and apply the settings.
- That’s it. Now commit (and push) your project.