Android – How to connect existing Android Studio project to existing Github repository

androidandroid-studiogitgithub

So I am new to Android development and Android Studio.

I used Android Studio to create an Android project, and each time I wanted to commit the code to GitHub, I switched over to the command line and committed/pushed the code from there.

However, I realize now that Android Studio has it's own features for connecting to GitHub. I'd like to use those features.

Since the project already exists, I prefer not to just create a new GitHub repository from Android Studio and delete the old one. I just want to connect the existing GitHub repository with the Android Studio project.

How can I sync these up?

Best Answer

Maybe it is a little bit late, but if it helps to someone here is what I do in command line:

cd <proyect folder>
git init
git remote add origin <link to repo>
git fetch origin
git checkout master

note: if there are commits on the repo it may require you to remove conflicting files

git add --all
git commit -m "<message>"
git push